REJECT 拒绝通过,必要时给出提示
LOG 记录日志信息,然后传给下一条规则继续匹配
———————
匹配条件【参数】
【linux防火墙过滤技术iptables的原理及操作命令详解】通用匹配:
协议匹配 -p [协议名]
地址匹配 -s [源地址] -d [目的地址]
接口匹配 -i [入站网卡] 、-o [出站网卡]
隐含匹配(需配合通用匹配一起使用):
端口匹配 --sport [源端口]、--dport [目的端口]
TCP标记端口 --tcp-flags [检查范围] [被设置的标记]
ICMP类型匹配 --icmp-type [ICMP类型]
常见的显示匹配条件
多端口匹配 -m multiport -- sport [源端口列表]、-m multiport -- sport [目的端口列表]
IP范围匹配 -m iprange --src-range [IP范围]
mac地址匹配 -m mac --mac-source [MAC地址]
———————
注意事项:
不指定表名时,默认指向filter表
不指定链名时,默认表内所有链
除非设置链的默认策略,否则必须指定匹配条件
选项、链名、控制类型使用大写字母,其余均为小写
————————————————
[root@xing Desktop]# iptables -t filter -I INPUT -p tcp --dport 80 -j ACCEPT
注:命令严格区分大小写
———————
辅助命令:watch(可以帮你监测一个命令的运行结果)
格式:watch (选项) (参数)
选项
-n:指定指令执行的间隔时间(秒);
-d:高亮显示指令输出信息不同之处;
-t:不显示标题 。
参数
指令:需要周期性执行的指令 。
watch -n1 iptables -t filter -nvL
————————————————
规则备份与还原
iptables-save工具:可结合重定向输出保存到指定文件
将当前状态保存到一个桌面的文件中
[root@xing Desktop]# iptables-save > /root/Desktop/ipt.txt
将备份规则文件导入:
[root@xing Desktop]# iptables-restore < /root/Desktop/ipt.txt
将当前状态保存为默认规则
[root@xing Desktop]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
恢复到默认规则
[root@xing Desktop]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
————————————————
[root@xing Desktop]# iptables -t nat -nvL --line-number
[root@xing Desktop]# iptables -t nat -A POSTROUTING -p tcp -o eth1 -s 172.168.1.0/24 -j SNAT --to-source 12.34.56.89
[root@xing Desktop]# iptables -t nat -A POSTROUTING -p tcp -o eth1 -s 172.168.1.0/24 -j MASQUERADE
推荐阅读
- Linux|彻底弃用Intel处理器:Linux之父把台式机、笔记本全换了
- AMD|Windows下干不过 AMD悄然在Linux系统上超越Intel
- Linux|Linux 5.19内核发布 支持国产CPU龙芯自研指令集
- Linux|国产操作系统上新:深度Deepin官宣23版本8月发布
- 电脑设置开启禁用网络安全防火墙 电脑防火墙在哪里设置
- 如何关闭防火墙(关闭Windows防火墙的四种方法)
- linux系统怎么关闭selinux?
- 如何发送邮件(如何用Linux命令行发送邮件)
- Linux通过特殊关键字查询文件路径
- linux系统搭建ftp服务器及创建用户
