- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2018-07-07T08:33:47+00:00","default:masatomix","masatomix")
#topicpath
----
#contents
** iptables を使う [#j2541d94]
# sudo apt install iptables
**バージョン確認 [#k092b32d]
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"
*** リスト表示 [#pbeadb90]
# sudo iptables -L
# sudo iptables --list -n -v
*** install直後の初期状態 [#a68ecb7c]
# sudo iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
** chkconfigがない。 [#f4350efb]
かわりに sysv-rc-conf があるみたい。
# sudo apt install sysv-rc-conf
*** たとえば、HTTPは任意のIPから許可。 [#e40645f7]
# sudo iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
試してみる。
# sudo sysv-rc-conf --list | grep apache2
apache2 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# sudo sysv-rc-conf apache2 --level 345 off
# sudo sysv-rc-conf --list | grep apache2
apache2 0:off 1:off 2:on 3:off 4:off 5:off 6:off
# sudo sysv-rc-conf apache2 --level 345 on
# sudo sysv-rc-conf --list | grep apache2
apache2 0:off 1:off 2:on 3:on 4:on 5:on 6:off
*** たとえばsshは所定のIPだけ許可 [#g7bf4a90]
# iptables -A INPUT -p tcp -s 192.168.0.24/32 --dport 22 -j ACCEPT
chkconfigとおんなじじゃないか。
sudo sysv-rc-conf でUIっぽくみることが出来る。。
*** 設定の保存 [#ub3b26e8]
# sudo apt list iptables-persistent
# sudo apt install iptables-persistent
というか、そもそもchkconfig ってLinux全体でディスコンになってるぽいし、Ubuntuもただしくはsystemctl 使うのが正しいようですね。
保存と、読み込み
# sudo /etc/init.d/netfilter-persistent save
# sudo /etc/init.d/netfilter-persistent reload
[[ubuntu server 16.04.2でsystemdから自動起動 - JP7FKFの備忘録>http://jp7fkf.hatenablog.jp/entry/2017/05/28/225946]]
-[[UbuntuをWebサーバで使う時のiptablesの例 - DB@WEB>http://dbweb.0258.net/wiki.cgi?page=Ubuntu%A4%F2Web%A5%B5%A1%BC%A5%D0%A4%C7%BB%C8%A4%A6%BB%FE%A4%CEiptables%A4%CE%CE%E3]]
-[[Ubuntuでiptablesの設定をiptables-persistentで永続化する>http://iwashi.co/2015/01/16/ubuntu-iptables-persistent]]
-[[iptablesの設定 入門編 - Murayama blog.>http://murayama.hatenablog.com/entry/20100206/1265444193]]
-[[iptablesの設定方法 さくらのサポート情報>https://help.sakura.ad.jp/hc/ja/articles/206208121-iptables%E3%81%AE%E8%A8%AD%E5%AE%9A%E6%96%B9%E6%B3%95]]
** systemctlの件。 [#h28fd996]
$ sudo systemctl get-default
graphical.target
[[Linux女子部 systemd徹底入門>https://www.slideshare.net/enakai/linux-27872553]]
----
この記事は
#vote(おもしろかった,そうでもない)
#comment
#topicpath
SIZE(10){現在のアクセス:&counter;}