当前位置: 移动技术网 > 网络运营>服务器>Linux > Centos 7开启网卡自动获取IP的详细方法

Centos 7开启网卡自动获取IP的详细方法

2019年04月24日  | 移动技术网网络运营  | 我要评论

centos7默认安装是没有开启配置网卡信息的,无法访问外网。

下边配置打开网络自动获取ip地址

1.查看网卡信息

执行ifconfig

eno16777736: flags=4163<up,broadcast,running,multicast> mtu 1500

    inet6 fe80::20c:29ff:fee8:8637 prefixlen 64 scopeid 0x20<link>

    ether 00:0c:29:e8:86:37 txqueuelen 1000 (ethernet)

    rx packets 1121 bytes 98968 (96.6 kib)

    rx errors 0 dropped 0 overruns 0 frame 0

    tx packets 179 bytes 25233 (24.6 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 900 bytes 78372 (76.5 kib)

    rx errors 0 dropped 0 overruns 0 frame 0

    tx packets 900 bytes 78372 (76.5 kib)

    tx errors 0 dropped 0 overruns 0 carrier 0 collisions 0 

1.eno16777736代表网卡的名称,ether 00:0c:29:e8:86:37代表网卡的mac地址

2.配置网卡开始网络连接

cd /etc/system/network-scripts/

vi ifcfg-eno16777736 
hwaddr=00:0c:29:e8:86:37
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=79d6c916-aab8-45e4-a163-37ae73393d26
onboot=no

将onboot= no改成onboot=yes

3.重启网络

service network restart

4.再执行ifconfig

eno16777736: flags=4163<up,broadcast,running,multicast> mtu 1500
    inet 192.168.159.128 netmask 255.255.255.0 broadcast 192.168.159.255
    inet6 fe80::20c:29ff:fee8:8637 prefixlen 64 scopeid 0x20<link>
    ether 00:0c:29:e8:86:37 txqueuelen 1000 (ethernet)
    rx packets 1699 bytes 140091 (136.8 kib)
    rx errors 0 dropped 0 overruns 0 frame 0
    tx packets 333 bytes 42669 (41.6 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 900 bytes 78372 (76.5 kib)
    rx errors 0 dropped 0 overruns 0 frame 0
    tx packets 900 bytes 78372 (76.5 kib)
    tx errors 0 dropped 0 overruns 0 carrier 0 collisions 0

inet 192.168.159.128 代表ip地址

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网