開啓Ubuntu的NAT網絡共享(封包轉發方式局域網內共享上網)

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 -F

iptables -P INPUT ACCEPT

iptables -P FORWARD ACCEPT

iptables -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 deviceGoogle 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
發佈了26 篇原創文章 · 獲贊 5 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章