LoginSignup
14
13

More than 5 years have passed since last update.

ufwをcentosにインストール

Posted at

iptablesを直接いじりたくないのでufwを導入します。

sudo yum install wget make
mkdir -p ~/src
cd ~/src
wget https://launchpad.net/ufw/0.33/0.33/+download/ufw-0.33.tar.gz
tar xzf ufw-0.33.tar.gz
cd ufw-0.33
sudo python ./setup.py install
cd ../
sudo rm -rf ufw-0.33
sudo chmod -R g-w /etc/ufw /lib/ufw /etc/default/ufw /usr/sbin/ufw

sudo service iptables stop
sudo service ip6tables stop
sudo chkconfig --del iptables
sudo chkconfig --del ip6tables

$ sudo ufw status
Status: inactive

$ sudo ufw reset
$ sudo ufw default deny
$ sudo ufw allow 22
$ sudo ufw allow 80
$ sudo ufw allow 443
$ sudo ufw enable
$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
80                         ALLOW       Anywhere
443                        ALLOW       Anywhere
22                         ALLOW       Anywhere (v6)
80                         ALLOW       Anywhere (v6)
443                        ALLOW       Anywhere (v6)

念のため別コンソール開いてssh繋がるか確認してください(ssh繋げたまま)

次は常時起動設定

sudo sh -c "echo '/usr/sbin/ufw enable' >> /etc/rc.local"
$ sudo cat /etc/rc.local | tail -3 # 念のため確認

touch /var/lock/subsys/local
/usr/sbin/ufw enable
$ sudo reboot

立ち上がったらちゃんと起動できてるか確認

$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
80                         ALLOW       Anywhere
443                        ALLOW       Anywhere
22                         ALLOW       Anywhere (v6)
80                         ALLOW       Anywhere (v6)
443                        ALLOW       Anywhere (v6)

お疲れ様でした

参考: http://mitsuakikawamorita.com/blog/?p=1375
参考: http://g6g6g6g6g6.tumblr.com/post/64294729570/centos-utf

14
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
13