LoginSignup
11
13

More than 5 years have passed since last update.

iptables周りの備忘録

Posted at

現状登録されている設定内容を行番号付きで確認する

$ /sbin/iptables -L -n --line-number

指定した行番号へiptablesの設定追加する

# /sbin/iptables -I INPUT {行番号} -s {IP/サブネットマスク} -p tcp -m tcp --dport {ポート番号} -j ACCEPT
$ /sbin/iptables -I INPUT 11 -s xxx.xxx.xxx.xxx/255.255.255.255 -p tcp -m tcp --dport 443 -j ACCEPT

iptablesのコンフィグにも保存(再起動した際も反映するようにするため)

$ /etc/init.d/iptables save

iptablesのコンフィグにも設定保存されてることを確認する

$ cat /etc/sysconfig/iptables

間違えて設定入れた時に行番号指定して消すコマンド

# /sbin/iptables -D INPUT {行番号}
$ /sbin/iptables -D INPUT 15

iptablesを再起動した際に、iptablesモジュールをunloadしないようにする設定

window scale optionを無効にする

# 現状のwindow scale optionの確認
[test-user@hoge ~]$ cat /proc/sys/net/ipv4/tcp_window_scaling
1

# iptablesのコンフィグ確認
[root@hoge ~]# grep UNLOAD /etc/sysconfig/iptables-config
IPTABLES_MODULES_UNLOAD="yes"

# IPTABLES_MODULES_UNLOADをnoにする
[root@hoge ~]# vim /etc/sysconfig/iptables-config
IPTABLES_MODULES_UNLOAD="no"

# iptablesの再起動(iptablesモジュールの取り外しが行われなくなる)
[root@hoge ~]# /etc/init.d/iptables restart
11
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
11
13