测试环境:
1 2
| [root@localhost ~] CentOS Linux release 7.0.1406 (Core)
|
查找网卡信息
找到要修改的网卡,比如我这里的是 eno16777736
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| [root@localhost ~] eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.204.128 netmask 255.255.255.0 broadcast 192.168.204.255 inet6 fe80::20c:29ff:fe43:2fd1 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:43:2f:d1 txqueuelen 1000 (Ethernet) RX packets 93 bytes 10339 (10.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 102 bytes 12391 (12.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 15 bytes 1329 (1.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 15 bytes 1329 (1.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
修改配置
找到 eno16777736 这个网卡对应的配置文件,编辑
文件默认配置是这样的(后面的注释是我加上去的):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| HWADDR=00:0C:29:43:2F:D1 TYPE=Ethernet BOOTPROTO=dhcp DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no NAME=eno16777736 UUID=0c9115ee-a2b3-47bc-b2b9-efecb596e108 ONBOOT=yes
|
现在要做的就是更改为如下配置,后面的几个项根据自己实际情况配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| HWADDR=00:0C:29:43:2F:D1 TYPE=Ethernet
DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no NAME=eno16777736 UUID=0c9115ee-a2b3-47bc-b2b9-efecb596e108 ONBOOT=yes
BOOTPROTO=static IPADDR=192.168.204.136 GATEWAY=192.168.204.1 NETMASK=255.255.255.0
|
重启网络服务
别忘了重启网络服务