开启Ubuntu的NAT网络共享(封包转发方式局域网内共享上网)

来源:互联网 发布:光盘刻录软件哪个好 编辑:程序博客网 时间:2024/06/11 01:59
  • We need open the ipv4 forwarding on the host 
    sysctl -w net.ipv4.ip_forward = 1

  • Add follow lines into /etc/rc.locat to set NAT table
    iptables -Fiptables -P INPUT ACCEPTiptables -P FORWARD ACCEPTiptables -t nat -A POSTROUTING -o [Sharing interface name] -j MASQUERADE      
  • Reboot the host device to enable the settings.
  • Set the host device IP (如果是多网卡方式组建局域网,需将网关设置为连接外网的网卡的IP, 内网网卡仅仅作AP点用)as gateway on the associate device
  • Google DNS server can be use Google free DNS 8.8.8.8 | 8.8.4.4 or OpenDNS 208.67.222.222 | 208.67.220.220
  • 原创粉丝点击