1. 程式人生 > >linux 設定靜態ip

linux 設定靜態ip

# The primary network interface
auto eth0
iface eth0 inet dhcp

設定靜態ip的方法如下:
1) 編輯 /etc/network/interfaces
1.1)將dhcp 一行遮蔽
# The primary network interface
auto eth0
#iface eth0 inet dhcp

1.2)新增和靜態ip有關的引數
# The primary network interface
iface eth0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1

2)編輯 /etc/resolv.conf,設定dns

nameserver 202.96.134.133
nameserver 202.106.0.20

3)執行下面兩個命令,啟用新設定
$sudo ifdown eth0 
$sudo ifup eth0