一、centos下

网络的配置文件/etc/sysconfig/network-scripts/
 

#DEVICE="eth0"
#BOOTPROTO="dhcp"
#HWADDR="00:0C:29:BA:FF:A9"
#NM_CONTROLLED="yes"
#ONBOOT="yes"
#TYPE="Ethernet"
#UUID="975a70b2-e0f3-4f00-9e67-f966e177d2db"

#Custemed configuration!
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
IPADDR=192.168.0.110
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
NETWORK=192.168.0.0
BROADCAST=192.168.0.255
#PREFIX=24
DNS1=202.106.0.20
#DEFROUTE=yes
#IPV6INIT=no
 

修改生效 service network restart
 

二、ubuntu

配置文件位置/etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.0.111
netmask 255.255.255.0
gateway 192.168.0.1
 

修改生效sudo /etc/init.d/network restart