#yyds干货盘点#iptables常用命令
Posted 散人君莫笑
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了#yyds干货盘点#iptables常用命令相关的知识,希望对你有一定的参考价值。
iptables常用命令
3、删除
删除用-D参数
删除之前添加的规则(iptables -A INPUT -s 192.168.1.5 -j DROP):
[root@test ~]# iptables -D INPUT -s 192.168.1.5 -j DROP
有时候要删除的规则太长,删除时要写一大串,既浪费时间又容易写错,这时我们可以先使用–line-number找出该条规则的行号,再通过行号删除规则。
[root@test ~]# iptables -nv --line-number
iptables v1.4.7: no command specified
Try `iptables -h or iptables --help for more information.
[root@test ~]# iptables -nL --line-number
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 DROP all -- 192.168.1.1 0.0.0.0/0
2 DROP all -- 192.168.1.2 0.0.0.0/0
3 DROP all -- 192.168.1.3 0.0.0.0/0
删除第二行规则
[root@test ~]# iptables -D INPUT 2
1、添加对 114.32.207.47 的过滤(直接 DROP 掉)
iptables -I INPUT -s 107.182.21.232 -j DROP
2、检查设置是否正常
iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all -- 114-32-207-47.HINET-IP.hinet.net anywhere
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@yyy-160-19 ~]# history |grep iptables
24 vi /etc/sysconfig/iptables
25 service iptables restart
67 chkconfig iptables pff
68 chkconfig iptables off
97 vi /etc/sysconfig/iptables
100 vi iptables
102 iptables -L
104 iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 添加端口映射。把80端口映射为8080.
105 iptables -L
108 iptables -L
109 iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 801
110 iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 801
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 80115:56 2017/5/27 星期六
iptables -t nat -A PREROUTING -p udp -m udp --dport 80 -j REDIRECT --to-ports 801
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A PREROUTING -p udp -m udp --dport 80 -j REDIRECT --to-ports 8080
111 cd /etc/sysconfig/iptables
112 more /etc/sysconfig/iptables
113 more /etc/sysconfig/iptables-config
114 iptables -L
116 iptables -L
117 iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
118 iptables -L
197 iptables status
198 service iptables status
205 iptables -L
206 iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
207 iptables -L
208 iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
209 iptables -L
211 iptables -L
212 iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
213 iptables -L
215 iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
216 service iptables startus
217 service iptables status
218 iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
219 service iptables save
220 iptables-save > /soft/iptables-20170517
221 iptables-save > /root/iptables-20170517
223 history |grep iptables
iptables -A OUTPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -L
iptables -A FILTER -p tcp --dport 80 -s 10.10.8.230 -d 10.10.8.221 -j aACCEPT
iptables -A FILTER -p tcp --dport 80 -s 10.10.8.230 -d 10.10.8.221 -j -ACCEPT
iptables -A FILTER -p tcp --dport 80 -s 10.10.8.230 -d 10.10.8.221 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -s 10.10.8.230 -d 10.10.8.221 -j ACCEPT
more iptables
iptables -A OUTPUT -p tcp -m tcp --dport 80 -j DROP
iptables -L
iptables save
iptables -save
service iptables save
iptables-save ?
iptables-save /pys/iptables-20170417
iptables-save > /pys/iptables-20170417
more iptables-20170417
iptables -L
iptables -L
iptables -nL --line-number
iptables -D OUTPUT 1
iptables -L
以上是关于#yyds干货盘点#iptables常用命令的主要内容,如果未能解决你的问题,请参考以下文章