歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> 更多Linux >> 如何讓Linux使用ADSL聯機分享

如何讓Linux使用ADSL聯機分享

日期:2017/2/27 14:18:15   编辑:更多Linux
  目前許多 Linux Distribution 都已經把 IP Masquerade 支持編入到kernel 內了,所以重編 kernel 的部份可以略過,剩下的就是專心於把 IP Forwarding 打開,並使用 ipchains 程序來設定即可。 另外就是,連上 internet 的 linux 主機 ip 假設是 210.222.111.100 而 Client 端要上網的 IP 就是使用 192.168.1.x (x: 1 ~ 254) 。 那 Linux 主機要加裝第二個網絡卡,IP 設定為 192.168.1.1,Client 端的主機 IP 就使用 192.168.1.x (x: 2 ~ 254),netmask 為 255.255.255.0 而 gateway 就指向 Linux 主機的 192.168.1.1 IP 位置。希望使用單一網絡卡的話,請設定使用 eth0:0 這個 IP Alias 的方式把 IP 設定為192.168.1.1 即可。這個部份使用 RedHat LINUX 的話,可以使用 netconf程序,在IPaliases for virtual hosts 裡面來設定。手動的話,就是使用ifconfig eth0:0 192.168.1.1 netmask 255.255.255.0 即可。 OK.. 只要 Linux 主機把 IP Forwarding 打開,並使用 ipchains 程序設定好後,Client 端就可以透過 Linux 這台 gateway 主機的協助而上網了。 ipchains -P forward DENY ipchains -A forward -j MASQ -s 192.168.1.0/24 -d 0.0.0.0/0 IP Forwarding ,redhat 可以使用 netconf 程序,在 Routing and gateways ---> Set Defaults ,把 Enable routing 選起來即可。或者是改 /etc/sysconfig/network 檔案,把 FORWARD_IPV4= 設定為 "yes" 即可。 而這個步驟,其實就是把 /proc/sys/net/ipv4/ip_forward 檔案內容改成 1




Copyright © Linux教程網 All Rights Reserved