iptables表的备份和恢复、firewalld的9个zone、zone操作、service操作

service iptables save
iptables-save > my.ipt
iptables-restore < my.ipt
iptables -t nat -F
iptables -t nat -nvL
iptables-restore </tmp/ipt.txt

systemctl disable iptables
systemctl stop iptables
systemctl enable firewalld
systemctl start firewalld
firewalld默认有9个zone.zone是firewalld单位
默认zone为public。每隔zone相当于一个规则集
firewall-cmd --get-zones //查看所有zone
firewall-cmd --get-default-zone//查看默认zone

firewall-cmd --set-default-zone=work //设定默认zone
firewall-cmd --get-default-zone //查看默认的zone
firewall-cmd --get-zone-of-interface=eno16777728 //查指定网卡
firewall-cmd --get-zone-of-interface=eno33554960
no zone

如果后面添加的网卡no zone设置如下:
cd /etc/sysconfig/network-scripts/
把eno16777728复制一份改成eno33554960修改配置文件。重启服务在加载firewalld服务
systemctl restart firewalld

firewall-cmd --zone=public --add-interface=lo //给指定网卡设置zone 
firewall-cmd --zone=dmz --change-interface=lo //针对网卡更改zone
firewall-cmd --zone=dmz --remove-interface=lo //针对网卡删除zone 
firewall-cmd --get-active-zones //查看系统所有网卡所在的zone

firewall-cmd --get-services 查看所有的servies(service是zone的子单元。理解为指定的一个端口)
firewall-cmd --list-services //查看当前zone下有哪些service
firewall-cmd --zone=public --list-service //查看public有哪些service
firewall-cmd --zone=public --add-service=http //把http增加到public zone下面(也只是加载到内存里,把配置加到配置文件里去)
firewall-cmd --zone=public --remove-service=http
ls /usr/lib/firewalld/zones/ //zone的配置文件模板
firewall-cmd --zone=public --add-service=http --permanent //更改配置文件,之后会在/etc/firewalld/zones目录下面生成配置文件
需求:ftp服务自定义端口1121,需要在work zone下面放行ftp
cp /usr/lib/firewalld/services/ftp.xml /etc/firewalld/services
vi /etc/firewalld/services/ftp.xml //把21改为1121
cp /usr/lib/firewalld/zones/work.xml /etc/firewalld/zones/
vi /etc/firewalld/zones/work.xml //增加一行
<service name="ftp"/>
firewall-cmd --reload //重新加载
firewall-cmd --zone=work --list-services



本文转自 虾米的春天 51CTO博客,原文链接:http://blog.51cto.com/lsxme/2046369,如需转载请自行联系原作者

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值