Debian / Ubuntu Linux 的網路設定, 若不使用 NetworkManager 的話, 就是要手動設定 /etc/network/interfaces.
網路設定範例
/etc/network/interfaces 有哪些參數可以設定? 下面把常用的都列出來.
- DHCP (自動取得 IP)
auto eth0
iface eth0 inet dhcp - Static IP (固定/靜態 IP)
iface eth0 inet static
address 192.168.0.7
netmask 255.255.255.0
gateway 192.168.0.254 - PPPoE
auto dsl-provider
iface dsl-provider inet ppp
pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf
provider dsl-providerauto eth0
iface eth0 inet manual - 更多設定
auto eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.254
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 168.95.1.1 168.95.192.1 8.8.8.8 8.8.4.4
dns-search longwin.com.twauto eth0
iface eth0:0 inet static
address 192.168.1.41
netmask 255.255.255.0
broadcast 192.168.1.255
除此之外, 還想要做些進階設定, 例如下述:
- 設定 DHCP Client, fault tolerant bonding, multiple IP... 等, 可以參考此篇: NetworkConfiguration - Debian Wiki
- 設定 Bridge Network, 參考此篇: BridgeNetworkConnections - Debian Wiki
- IPv6 設定 / 開關方式 / 6to4, 參考此篇: DebianIPv6 - Debian Wiki
實用的設定檔,按個讚