[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0#网卡设备名称
ONBOOT=yes#启动时是否激活 yes | no
BOOTPROTO=static#协议类型 dhcp bootp none
IPADDR=192.168.1.90#网络IP地址
NETMASK=255.255.255.0#网络子网地址
GATEWAY=192.168.1.1#网关地址
BROADCAST=192.168.1.255#广播地址
HWADDR=00:0C:29:FE:1A:09#网卡MAC地址
TYPE=Ethernet#网卡类型为以太网
注:在修改文件ifcfg-ethx后还需要重新导入文件才能生效,具体命令如下:
[[email protected]
~]# /etc/init.d/network reload #命令有start | restart | stop | reload
例子:
1.临时:
ifconfig eth0 172.16.12.244 netmask 255.255.255.0
ip route add default via 172.16.12.1
2.centos手工:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth1"
BOOTPROTO="static"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
IPADDR="172.16.12.218"
NETMASK="255.255.255.0"
GATEWAY="172.16.12.1"
DNS1="172.16.12.1"
DNS2="114.114.114.114"
3 UBUNTU 手工
auto eth0
iface eth0 inet static
address 172.16.12.215
netmask 255.255.255.0
network 172.16.12.0
broadcast 172.16.12.255
gateway 172.16.12.1
dns-nameservers 172.16.12.101 8.8.8.8
up route add -net 172.16.1.0 netmask 255.255.255.0 gw 172.16.*.*