初次安装好CentOS7后网络可能还未开启。需要自己手动配置。
Type “nmcli d” command in your terminal for quick identification of Ethernet cards installed in your machine.
Step 1 » Network interface config files are located in /etc/sysconfig/network-scripts/ directory. Open ifcfg-enp0s17 file ( For interface enp0s17 ) and you can see the content like below.[root@krizna ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s17
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s17
UUID=7f1aff2d-b154-4436-9497-e3a4dedddcef
ONBOOT=no
HWADDR=00:0C:29:A1:B5:D6
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
» DHCP configuration
Step 2 » For DHCP
Find the below lines in config File.BOOTPROTO=none
and replace with
ONBOOT=noBOOTPROTO=dhcp
Now Restart network service by typing below command.
ONBOOT=yessystemctl restart network
Now your server will get IP Address from DHCP
参考资料