iptables 配置指令碼

2022-05-05 17:12:10 字數 1557 閱讀 3191

-a input -s 10.0.0.1 -p tcp --dport 8000 -m comment --comment "源ip-->目標:埠" -j accept
-a input -p tcp -m multiport --dports 8080:8090 -m comment --comment "新增連續多埠" -j accept
-a input -p tcp -m multiport --dports 22,80,443 -m comment --comment "新增非連續多埠" -j accept
-a input -m iprange --src-range 122.10.27.100-122.10.27.200 -p udp --dport 7087 -m comment --comment "新增連續ip" -j accept
-a input -p tcp -m time --timestart 02:00--timestop 03:00  -m comment --comment "凌晨 2 點到 3 點之間拒絕所有的 tcp訪問" -j drop

-a input -p udp -m time --timestart 02:00--timestop 03:00 -m comment --comment "凌晨 2 點到 3 點之間拒絕所有的 udp 訪問" -j drop

-a input -p tcp -syn -m multiport -dport http,https -m connlimit --connlimit-above 20 -m comment --comment "限制單個ip位址到伺服器建立連線的數量為20,防止dos攻擊" -j reject --reject-with-tcp-reset
-a output  -p tcp  -m multiport  --dport http,https  -i eth0  -o eth1  -m time --timestart 12:00  -timestop 13:00  -d 31.13.64.0/18 -m comment --comment "在12點到13點之間允許到 31.13.64.0/18的 http和https的訪問" -j accept
-a input -p tcp -m tcp --tcp-flags syn,ack syn,ack -m state --state new -m comment --comment "拒絕tcp標記為syn/ack但連線狀態為new的資料報,防止ack欺騙" -j reject --reject-with tcp-reset

-a input -p tcp -m tcp ! --tcp-flags fin,syn,rst,ack syn -m state --state new -m comment --comment "拒絕tcp除了標記為fin,syn,rst,ack syn之外的,但連線狀態為new的資料報,防止介面堵塞"-j reject --reject-with tcp-reset

iptables 配置例項

iptables f iptables x iptables f t mangle iptables t mangle x iptables f t nat iptables t nat x 首先,把三個表清空,把自建的規則清空。iptables p input drop iptables p ou...

iptables配置例項

bin bash export iptables sbin iptables export eth0 enp3s0 清除所有規則 iptables f iptables x 設定規則 iptables p input drop 不在此規則裡的資料報丟棄 iptables p output accep...

iptables 配置略記

使用iptables配置的頻率非常低,但每次都要查一下資料,還是比較麻煩的。其實命令看起來繁瑣,還是有規律可記的。首先,iptables help 下,看下大概的命令引數。新增進入規則 b iptables a chainname p tcp dport 8081 j accept b 其中chai...