CentOS7.0 安装网卡配置

CentOS 7.0 在VMware虚拟机上安装好后,默认是没有配置网卡的,使用ifconfig指令,只能看到一块没有IP地址的接口和本地回环接口.

[user@localhost ~]$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 00:0c:29:e2:ef:21  txqueuelen 1000  (Ethernet)
        RX packets 22932  bytes 31671473 (30.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7888  bytes 562229 (549.0 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
        loop  txqueuelen 1  (Local Loopback)
        RX packets 10  bytes 512 (512.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 512 (512.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

原因是没有打开网卡的DHCP服务,没有IP地址,需要在配置文件里面修改ONBOOT=yes,BOOTPROTO=dhcp。

[user@localhost ~]$ sudo vi /etc/sysconfig/network-scripts/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=902c5a27-1a23-4f2d-ba32-a19dad3c4587
DEVICE=ens33
ONBOOT=yes

修改完成后保存退出,使用”service network restart” 重新启动网络,就可以看到分配了正确的IP地址

[user@localhost ~]$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.123.188  netmask 255.255.255.0  broadcast 192.168.123.255
        inet6 fe80::d4a0:2f2:ee9e:6e3b  prefixlen 64  scopeid 0x20
        ether 00:0c:29:e2:ef:21  txqueuelen 1000  (Ethernet)
        RX packets 23772  bytes 31860851 (30.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8089  bytes 591779 (577.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

你可能感兴趣的:(Linux)