这里有新鲜出炉的精品教程,程序狗速度看过来!
CentOS(Community Enterprise Operating System,中文意思是:社区企业操作系统)是 Linux 发行版之一,它是来自于 Red Hat Enterprise Linux 依照开放源代码规定释出的源代码所编译而成。
本篇文章主要介绍了 Centos 7 开启网卡自动获取 IP 的详细方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
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 地址
来源: http://www.phperz.com/article/17/0818/337769.html