2013年3月14日木曜日

iptables2

http://blog.infinity-es.com/%E3%81%95%E3%81%8F%E3%82%89%E3%81%AEvps%E3%81%AB%E3%82%88%E3%82%8B%E3%80%80%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC%E5%85%A5%E9%96%807-iptables%E8%A8%AD%E5%AE%9A%E3%80%80/


↑そもそもiptableとはなんぞやってことから




http://www.turbolinux.co.jp/products/server/11s/user_guide/iptablesboot.html
今回の参考

iptablesってのは再起動すると消える
それを保存?する為に今回の作業が必要らしい。

それとこれ
http://d.hatena.ne.jp/mercysluck/20120211/p1
http://d.hatena.ne.jp/mercysluck/20121212


どうすればいいんだ( ̄Д ̄;)

とりあえず
/etc/iptables/rules.v4
/etc/iptables/rules.v6
を採用
と思ったらファイルが無いって言う
これはブログの人が作ったやつ?だと思うので



http://jitsu102.hatenablog.com/entry/2012/04/29/062417

こっちを採用

chkconfig iptables on
こっちを打ってもコマンドは見つかりませんって言われるので・・・



とりあえずiptables-persistentをインストール
aptitude install iptables-persistent

まずバックアップ
sudo cp rules rules_bk
■ルールの設定ファイルを作成
sudo vi /etc/iptables/iptables.rules

前回適用した設定を流し込み
sudo iptables-save > /etc/iptables/rules

そして戻してみる

# iptables-restore < /etc/iptables/iptables.rules

ファイル名が違うので正しくは

# iptables-restore < /etc/iptables/rules
確認として
iptables -L





一度リセットしてみる
iptables -F

すると
iptables -L
===============================================================
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  
===============================================================

そしてもう一度
iptables-restore < /etc/iptables/rules

iptables -L
===============================================================
Chain INPUT (policy ACCEPT)
target     prot opt source               destination        
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ftp-data
ACCEPT     tcp  --  anywhere             anywhere            tcp spt:ftp-data
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ftp
ACCEPT     tcp  --  anywhere             anywhere            tcp spt:ftp
ACCEPT     tcp  --  anywhere             anywhere            tcp spt:ftp-data
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ftp
ACCEPT     tcp  --  anywhere             anywhere            tcp spt:ftp
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:www
ACCEPT     tcp  --  anywhere             anywhere            tcp spt:www
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:pop3
ACCEPT     tcp  --  anywhere             anywhere            tcp spt:pop3
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:smtp
ACCEPT     tcp  --  anywhere             anywhere            tcp spt:smtp

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination        

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination        
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ftp-data
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:20
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ftp
ACCEPT     udp  --  anywhere             anywhere            state NEW udp dpt:fsp

===============================================================
ちゃんと入ってる。
バラスィー

ルールを/etc/iptables/rulesに反映させて、iptables-persistentを起動します。

# iptables-save > /etc/iptables/rules←さっきと同じことを・・・
# /etc/init.d/iptables-persistent start

iptables-persistentは起動時に/etc/iptables/rulesを適用してくれるらしい。
スバラスィー


http://jitsu102.hatenablog.com/entry/2012/04/29/062417
今回の参考

0 件のコメント :

コメントを投稿