海荻威深圳工业级PON
onu设备厂家,一家专门生产光网络设备的厂家,可为大家提供
EPON单口千兆ONU宽带接入光猫、
迷你型单口多口百兆千兆ONU光猫、以太无源光网络EPON设备、
千兆单模光模块、4口8口
epon olt设备等,今天小编给大家带来的文章介绍是千兆光猫iptables规则查看与清除
使用 iptables命令可以对具体的规则进行查看、添加、修改和删除
1) 查看规则
对规则的查看需要使用如下命令:
# iptables-nvL
各参数的含义为:
-L 表示查看当前表的所有规则,默认查看的是 filter 表,如果要查看 nat 表,可以加上 -t nat 参数。
-n 表示不对 IP 地址进行反查,加上这个参数显示速度将会加快。
-v 表示输出详细信息,包含通过该规则的数据包数量、总字节数以及相应的网络接口。
【例 1】查看规则。
在终端页面输入命令如下:
# iptables-L Chain INPUT (policy DROP)
target prot opt source destination
voip_chain all -- anywhere anywhere
ACCEPT udp -- anywhere 255.255.255.255 udp dpt:tftp state NEW
ACCEPT udp -- anywhere 255.255.255.255 udp dpt:tftp state NEW
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT udp -- anywhere anywhere udp dpt:router
2) 添加规则
添加规则有两个参数分别是 -A 和 -I。其中 -A 是添加到规则的末尾;-I 可以插入到指定位置,没有指定位置的话默认插入到规则的首部。
【例 2】查看当前规则。
在终端页面输入命令如下:
# iptables-nL --line-number 1 voip_chain all -- 0.0.0.0/0 0.0.0.0/0
2 ACCEPT udp -- 0.0.0.0/0 255.255.255.255 udp dpt:69 state NEW
3 ACCEPT udp -- 0.0.0.0/0 255.255.255.255 udp dpt:69 state NEW
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
5 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:520
6 DROP all -- 0.0.0.0/0 239.255.255.250
7 ACCEPT all -- 0.0.0.0/0 224.0.0.0/4
【例 3】添加一条规则到尾部。
在终端页面输入如下命令:
# iptables-A INPUT -s 192.168.1.5 -j DROP # iptables-nL --line-number Chain INPUT (policy DROP)
num target prot opt source destination
1 voip_chain all -- 0.0.0.0/0 0.0.0.0/0
2 ACCEPT udp -- 0.0.0.0/0 255.255.255.255 udp dpt:69 state NEW
3 ACCEPT udp -- 0.0.0.0/0 255.255.255.255 udp dpt:69 state NEW
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
5 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:520
6 DROP all -- 0.0.0.0/0 239.255.255.250
7 ACCEPT all -- 0.0.0.0/0 224.0.0.0/4
8 cwmp_aclblock all -- 0.0.0.0/0 0.0.0.0/0
9 domainblk all -- 0.0.0.0/0 0.0.0.0/0
10 tr069 all -- 0.0.0.0/0 0.0.0.0/0
11 inacc all -- 0.0.0.0/0 0.0.0.0/0
12 dhcp_port_filter all -- 0.0.0.0/0 0.0.0.0/0
13 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
14 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state NEW
15 DROP all -- 192.168.1.5 0.0.0.0/0
3) 修改规则
在修改规则时需要使用-R参数。
【例 4】把添加在第 15 行规则的 DROP 修改为 ACCEPT。
首先需要使用 su 命令,切换当前用户到 root 用户,然后在终端页面输入如下命令:
# iptables-R INPUT 15 -s 194.168.1.5 -j ACCEPT # iptables-nL --line-number
Chain INPUT (policy DROP)
num target prot opt source destination
1 voip_chain all -- 0.0.0.0/0 0.0.0.0/0
2 ACCEPT udp -- 0.0.0.0/0 255.255.255.255 udp dpt:69 state NEW
3 ACCEPT udp -- 0.0.0.0/0 255.255.255.255 udp dpt:69 state NEW
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
5 ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:520
6 DROP all -- 0.0.0.0/0 239.255.255.250
7 ACCEPT all -- 0.0.0.0/0 224.0.0.0/4
8 cwmp_aclblock all -- 0.0.0.0/0 0.0.0.0/0
9 domainblk all -- 0.0.0.0/0 0.0.0.0/0
10 tr069 all -- 0.0.0.0/0 0.0.0.0/0
11 inacc all -- 0.0.0.0/0 0.0.0.0/0
12 dhcp_port_filter all -- 0.0.0.0/0 0.0.0.0/0
13 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
14 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state NEW
15 ACCEPT all -- 194.168.1.5 0.0.0.0/0
对比发现,第 15 行规则的 target 已修改为 ACCEPT。
4) 删除规则
删除规则有两种方法,但都必须使用 -D 参数。
【例 5】删除添加的第 15 行的规则。
在终端页面输入如下命令:
# iptables-D INPUT 15 -s 194.168.1.5 -j ACCEPT
或
# iptables-D INPUT 15
注意,有时需要删除的规则较长,删除时需要写一大串的代码,这样比较容易写错,这时可以先使用 -line-number 找出该条规则的行号,再通过行号删除规则。
5)9607C查询iptables帮助命令行
# iptables--help
iptablesv1.4.18
Usage: iptables-[ACD] chain rule-specification [options]
iptables-I chain [rulenum] rule-specification [options]
iptables-R chain rulenum rule-specification [options]
iptables-D chain rulenum [options]
iptables-[LS] [chain [rulenum]] [options]
iptables-[FZ] [chain] [options]
iptables-[NX] chain
iptables-E old-chain-name new-chain-name
iptables-P chain target [options]
iptables-h (print this help information)
上一篇:【pon光纤猫棒厂家】SFP千兆单模光模块Linux iptables命令详解
下一篇:【嵌入式POE GPON ONU光模块厂家】125单口ONU WAN配置