查看有无网卡配置文件eth0和lo
[root@pwd network-scripts]# ls
ifcfg-eth0 ifdown-eth ifdown-isdn ifdown-sit ifup-bnep ifup-ipv6 ifup-post ifup-tunnel network-functions
ifcfg-lo ifdown-ib ifdown-post ifdown-tunnel ifup-eth ifup-isdn ifup-ppp ifup-wireless network-functions-ipv6
ifdown ifdown-ippp ifdown-ppp ifup ifup-ib ifup-plip ifup-routes init.ipv6-global
ifdown-bnep ifdown-ipv6 ifdown-routes ifup-aliases ifup-ippp ifup-plusb ifup-sit net.hotplug
[root@pwd network-scripts]# vim ifcfg-eth0
DEVICE=eth0
# If you're having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
ONBOOT=yes
NAME=eth0
BOOTPROTO=none
ONBOOT=yes
DNS2=8.8.8.8
TYPE=Ethernet
DNS1=114.114.114.114
NM_CONTROLLED=yes
PEERDNS=yes
IPV6INIT=no
IPADDR=192.168.110.131
NETMASK=192.168.110.131
GATEWAY=192.168.110.2
查看网络ip等设备信息
[root@pwd network-scripts]# ifconfig
eth1 Link encap:Ethernet HWaddr 00:0C:29:60:CB:3D
inet addr:192.168.110.131 Bcast:192.168.110.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe60:cb3d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10829 errors:0 dropped:0 overruns:0 frame:0
TX packets:6409 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:14176906 (13.5 MiB) TX bytes:459600 (448.8 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:32 errors:0 dropped:0 overruns:0 frame:0
TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2080 (2.0 KiB) TX bytes:2080 (2.0 KiB)
可以看见ifconfig中网卡设备名是eth1
更改配置文件eth0改成eth1
[root@pwd network-scripts]# vim ifcfg-eth0
DEVICE=eth1
# If you're having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
ONBOOT=yes
NAME=eth0
BOOTPROTO=none
ONBOOT=yes
DNS2=8.8.8.8
TYPE=Ethernet
DNS1=114.114.114.114
NM_CONTROLLED=yes
PEERDNS=yes
IPV6INIT=no
IPADDR=192.168.110.131
NETMASK=192.168.110.131
GATEWAY=192.168.110.2
成功
[root@pwd network-scripts]# service network restart
正在关闭接口 eth0: 设备状态:3 (断开连接)
[确定]
关闭环回接口: [确定]
弹出环回接口: [确定]
弹出界面 eth0: 活跃连接状态:已激活
活跃连接路径:/org/freedesktop/NetworkManager/ActiveConnection/1
[确定]