说一说iptables常见的几个小坑
1.添加一块网卡(虚拟机环境)
如果你原先只有一块10网段的外网网卡,现在为了测试防火墙添加一块内网网卡
注意,不只是添加一个配置文件就可以的哦,需要在虚拟机添加一块网卡,再配置配置文件才会生效
步骤如下:
1.选中虚拟机右击点击设置

2.点击添加

3.选择网络适配器

4.选择nat模式,启动时连接

5.选择LAN区段

2.测试共享上网的话,注意把10网段的网卡(外网)停掉
[root@m01 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
....
ONBOOT=no
....
即表示开机不启动,重启不启动
然后重启网卡即可生效
systemctl restart network
3.网关设置
注意把内网服务器的网关设置为防火墙的IP(嘿嘿嘿嘿)
4.开启转发
echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
sysctl -p
网友评论