1,修改靜態網絡配置
Java代碼
[root@davidserver ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="static"
HWADDR="00:0C:29:99:5A:3C"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="1cb095a6-b832-4dc1-92e1-1a1a7a58abc8"
IPADDR="8.0.0.10"
BROADCAST="8.0.0.255"
NETMASK="255.255.255.0"
NETWORK="8.0.0.0"
GATEWAY="8.0.0.1"
IPV6INIT="no"
IPV6_AUTOCONF="no"
簡化配置
Java代碼
[root@davidserver ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="static"
ONBOOT="yes"
TYPE="Ethernet"
IPADDR="8.0.0.11"
BROADCAST="8.0.0.255"
NETMASK="255.255.255.0"
NETWORK="8.0.0.0"
GATEWAY="8.0.0.1"
IPV6INIT="no"
IPV6_AUTOCONF="no"
2,修改DNS服務
Java代碼
[root@davidserver ~]# vim/etc/resolv.conf
nameserver 8.0.0.1
3,重啟網卡
Java代碼
[root@davidserver ~]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
輸出以上信息,代表成功了
or
Java代碼
[root@davidserver ~]# ifdown eth0; ifup eth0
www.2cto.com
同樣OK
4,雙網卡配置
Java代碼
[root@davidserver ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE="eth1"
BOOTPROTO="static"
ONBOOT="yes"
TYPE="Ethernet"
IPADDR="192.168.0.10"
BROADCAST="192.168.0.255"
NETMASK="255.255.0.0"
NETWORK="192.168.0.0"