一、centos6.8
1、在当前目录下
[root@hadoop3 network-scripts]# pwd
/etc/sysconfig/network-scripts
2、修改ifcfg-eth0配置
将ONBOOT改成yes
将NM_CONTROLLED改成no
DEVICE=eth2
HWADDR=00:0c:29:de:ae:63
TYPE=Ethernet
UUID=47865222-c953-47ff-a69e-67db918a9d27
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=dhcp
3、重启network
service network restart
4、查看ip
[root@hadoop3 network-scripts]# ifconfig
eth2 Link encap:Ethernet HWaddr 00:0C:29:DE:AE:63
inet addr:192.168.159.133 Bcast:192.168.159.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fede:ae63/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:240 errors:0 dropped:0 overruns:0 frame:0
TX packets:154 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:22435 (21.9 KiB) TX bytes:32049 (31.2 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:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
二、centos7
1、在当前目录下
[root@hadoop3 network-scripts]# pwd
/etc/sysconfig/network-scripts
2、修改ifcfg-ens33配置
将ONBOOT改成yes
[root@localhost network-scripts]# vi ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=dbd95852-cbc9-4c8d-a0c1-fc1474195ac7
DEVICE=ens33
ONBOOT=yes
3、重启network
service network restart
4、查看ip
[root@localhost network-scripts]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:62:9c:77 brd ff:ff:ff:ff:ff:ff
inet 192.168.159.139/24 brd 192.168.159.255 scope global noprefixroute dynamic ens33
valid_lft 1633sec preferred_lft 1633sec
inet6 fe80::e6f5:1f8a:8461:c73d/64 scope link noprefixroute
valid_lft forever preferred_lft forever