首页 > 代码库 > centos设置静态ip及出现的问题解决

centos设置静态ip及出现的问题解决

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

TYPE=Ethernet

ONBOOT=yes

UUID=cb2546d2-05fa-44a2-ac1e-c8fa0a9c1c00

NM_CONTROLLED=yes

BOOTPROTO=none

USERCTL=no

IPV4_FAILURE_FATAL=yes

IPV6INIT=no

NAME="eth0"

HWADDR=00:0C:29:C1:30:2A

PEERDNS=yes

PEERDNS=yes

IPADDR=192.168.208.104

NETMASK=255.255.255.0

DNS2=221.11.1.68

GATEWAY=192.168.208.2

DNS1=221.11.1.67

保存

service network restart

如果出现

[root@localhost ~]# service network restar

Shutting down interface eth0:  Device eth0 has MAC address 00:0C:29:C1:30:2A, instead of configured address 00:0C:29:F6:52:E4. Ignoring.

                                                           [FAILED]

Shutting down loopback interface:                          [  OK  ]

Bringing up loopback interface:                            [  OK  ]

Bringing up interface eth0:  Device eth0 has different MAC address than expected, ignoring.

                                                           [FAILED]

查看mac地址 cat /sys/class/net/eth0/address

编辑网卡配置文件vi /etc/sysconfig/network-scripts/ifcfg-eth0

修改HWADDR为执行cat /sys/class/net/eth0/address的结果

保存再重启网卡service network restart

[root@localhost ~]# service network restart 

Shutting down interface eth0:                              [  OK  ]

Shutting down loopback interface:                          [  OK  ]

Bringing up loopback interface:                            [  OK  ]

Bringing up interface eth0:  Determining if ip address 192.168.208.104 is already in use for device eth0...                                      [  OK  ]


centos设置静态ip及出现的问题解决