简单实现俩个私有内网之间的通讯
实验前配置准备
关闭firwalld和selinux 启动 iptables.service服务
pc1配置:
ip:172.16.10.100/24 网关:172.16.10.101 并安装httpd服务
pc2配置:
ip:192.168.10.100/24 网关:192.168.10.101 并安装httpd服务
fir1配置
网卡eth0:10.0.0.80/24
网卡eth1:172.16.10.101/24
fir2配置
网卡eth1:10.0.0.91/24
网卡eth0:192.168.10.101/24
用俩台linux服务器模拟防火墙
fir1 fir2都需要开启路由转发,配置如下
[root@fir1 ~]# echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
[root@fir1 ~]# sysctl -p
net.ipv4.ip_forward = 1
fir1和fir2都执行以上操作
防火墙路由配置:
fir1:ip route add 192.168.10.0/24 via 10.0.0.91
fir2:ip route add 172.16.10.0/24 via 10.0.0.80
为实现俩个私有网段之间的内网ip之间有公网做隔绝 就不在俩台PC上配置路由了 这样俩个pc之间通过内网ip是无法实现通信的
由于开启路由转发
实现1:内网可以访问公网而公网不能访问内网
fir2配置
root@fir2 ~]#iptables -t filter -A FORWARD -d 192.168.10.0/24 -m state --state NEW -j DROP
root@fir2 ~]#iptables -t filter -A IN