Fedora/Centos 1.找到設定網路介面的路徑vi /etc/sysconfig/network-scripts/ifcfg-eth0
設定內容:
DEVICE=eth0
#BOOTPROTO=dhcp BOOTPROTO=static IPADDR=192.168.1.1 NETMASK=255.255.255.0 NETWORK=192.168.1.0 GATEWAY=192.168.1.254 BROADCAST=192.168.1.255 ONBOOT=yes 在相同目錄下複製一份,並取名為例如ifcfg-eth0:0,內容大致如下即可 DEVICE=eth0:0 BOOTPROTO=static IPADDR=192.168.1.xxx NETMASK=255.255.254.0 NETWORK=192.168.1.0 GATEWAY=192.168.1.254 BROADCAST=192.168.1.255 ONBOOT=yes 最後重新啟動介面就好了,如果連eth0的設定都有變的話會斷線,所以其實我比較喜歡用重開機才不用跑去重啟:P ifup eth0:0
service network restart ------------------------------------------------------------ 底下是Debian/Ubuntu 1.找到設定網路介面的路徑vi etc/network/interfaces
設定內容:
auto eth0
在相同的檔案底下寫入即可,寫入內容大致如下
#iface eth0 inet dhcp iface eth0 inet static address 192.168.1.1 netmask 255.255.255.0 gateway 192.168.1.254 auto eth0:0
最後重新啟動網路設定就好了
iface eth0:0 inet static address 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255 gateway 192.168.1.254 /etc/init.d/networking restart
參考資料:高性能計算與網路實驗室 |