さくらの専用サーバー : iptables 設定。

まずは、設定をミスっても(無料)再起動で対応可能にしておく。

# /sbin/chkconfig iptables –list
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# /sbin/chkconfig iptables off
# /sbin/chkconfig iptables –list
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off

接続不能になったら再起動してもらいましょう。
設定完了確認後 on にしておきましょう。
または、起動後は自分でiptablesを実行することをお忘れなく。

まずは、つながらなくなると困るので
ポリシー設定 INPUT ACCEPT
/sbin/iptables -P INPUT ACCEPT
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -P FORWARD DROP
確認
/sbin/iptables -L
ルールを消す。
/sbin/iptables -F
/sbin/iptables -L
ローカルはすべて許可
/sbin/iptables -A INPUT -i lo -j ACCEPT
使うポートを設定
/sbin/iptables -A INPUT -p tcp –dport 80 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 22 -j ACCEPT
/sbin/iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
22は大丈夫かな?
/sbin/iptables -L
* 他は拒否する。
/sbin/iptables -P INPUT DROP
/sbin/iptables -L
外部から接続して問題なければ保存
/etc/init.d/iptables save

# /sbin/iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT tcp — anywhere anywhere tcp dpt:http
ACCEPT tcp — anywhere anywhere tcp dpt:ssh
ACCEPT all — anywhere anywhere state RELATED,ESTABLISHED
ACCEPT all — anywhere anywhere

Chain FORWARD (policy DROP)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

この状態で sshはつながるが ping は通らないのでOK

This entry was posted on 日曜日, 3月 28th, 2010 at 5:16 PM and is filed under blog, server, ssh. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。