iptables
linux内网利用iptables共享上网
一 上网机器设置,wlan0为互联网连接,eth0为内网网卡
1 设置/etc/sysctl.conf
net.ipv4.io_forward=1;
2 iptables规则
sudo iptables -t nat -A POSTROUTING -s 10.0.1.0/24 -o wlan0 -j MASQUERADE
3 /etc/network/interfaces
auto eth0 iface eth0 inet static address 10.0.1.1 netmask 255.255.255.0
局域网上网机器设置
1 /etc/network/interfaces
auto eth0 iface eth0 inet static address 10.0.1.2 gateway 10.0.1.1 netmask 255.255.255.0 dns-nameservers 8.8.8.8