- 追加された行はこの色です。
- 削除された行はこの色です。
#topicpath
----
#contents
** chkconfigがない。 [#f4350efb]
かわりに sysv-rc-conf があるみたい。
# sudo apt install sysv-rc-conf
** iptables を使う [#j2541d94]
# sudo apt install iptables
試してみる。
# 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
*** リスト表示 [#pbeadb90]
# sudo iptables -L
# sudo iptables --list -n -v
chkconfigとおんなじじゃないか。
sudo sysv-rc-conf でUIっぽくみることが出来る。。
*** 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 ってLinux全体でディスコンになってるぽいし、Ubuntuもただしくはsystemctl 使うのが正しいようですね。
[[ubuntu server 16.04.2でsystemdから自動起動 - JP7FKFの備忘録>http://jp7fkf.hatenablog.jp/entry/2017/05/28/225946]]
*** たとえば、HTTPは任意のIPから許可。 [#e40645f7]
# sudo iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
*** たとえばsshは所定のIPだけ許可 [#g7bf4a90]
# iptables -A INPUT -p tcp -s 192.168.0.24/32 --dport 22 -j ACCEPT
*** 設定の保存 [#ub3b26e8]
# sudo apt list iptables-persistent
# sudo apt install iptables-persistent
保存と、読み込み
# sudo /etc/init.d/netfilter-persistent save
# sudo /etc/init.d/netfilter-persistent reload
設定は
# sudo cat /etc/iptables/rules.v4
ココにされるようですね。
-[[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]]
***よくある設定? [#q6464a92]
# sudo iptables -F // remoteだとココで一旦きれちゃうので注意
# sudo iptables -P INPUT DROP // 自分への送信先のばあい、はすべて破棄
# sudo iptables -P FORWARD DROP // ルーティング?時はすべて破棄
# sudo iptables -P OUTPUT ACCEPT // 自分からの送信のばあい、はすべて許可
# sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT // 自分への送信かつ、自分の送信の応答受信のばあい
あとは個別に、使ってるポートだけ穴開け。
# sudo iptables -A INPUT -p tcp -s 192.168.0.0/24 --dport 22 -j ACCEPT
これでいいかな?
[[立ち上げ直後のiptablesを設定する。 - Qiita>http://qiita.com/shimohiko/items/ec672655edb84578a82e]]
** systemctlの件。 [#h28fd996]
$ sudo systemctl get-default
graphical.target
[[Linux女子部 systemd徹底入門>https://www.slideshare.net/enakai/linux-27872553]]
----
この記事は
#vote(おもしろかった,そうでもない)
#comment
#topicpath
SIZE(10){現在のアクセス:&counter;}