硬件要求
Linux作为网关:两块网卡eth0,eth1
eth0:外网ip,子网掩码,网关,dns
eth1:内网ip,子网掩码
clients:内网ip,子网掩码,网关为eth1_ip
配置
vi /etc/sysctl.conf
设置:
net.ipv4.ip_forward = 1
执行:
sysctl -p
应该看到
net.ipv4.ip_forward = 1
2. 局域网共享的两条命令方法
方法1:适合于有固定外网地址的:
iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0-j SNAT --to-source 192.168.1.198
(1)-s 10.0.0.0/24 办公室或IDC内网网段。
(2)-o eth0 为网关的外网卡接口。
(3)-j SNAT --to-source 192.168.1.198 是网关外网卡IP地址。
方法2:适合变化外网地址(ADSL):
iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -jMASQUERADE 伪装。
转载于:https://blog.51cto.com/chboy/1721573