#ens192为外网网卡, ens160为内网网卡
[root@dsrw ~]# iptables -F
[root@dsrw ~]# iptables -A FORWARD -i ens160 -j ACCEPT
[root@dsrw ~]# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o ens192 -j MASQUERADE
[root@dsrw ~]# vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
[root@dsrw ~]# sysctl -p
net.ipv4.ip_forward = 1
[root@dsrw ~]# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.2 netmask 255.255.255.0 broadcast 192.168.10.255
ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.9 netmask 255.255.255.0 broadcast 192.168.1.255
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
请登录后查看评论内容