Centos7默认安装是没有开启配置网卡信息的,无法访问外网。
下边配置打开网络自动获取Ip地址
1.查看网卡信息
执行Ifconfig
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | eno16777736: flags=4163 inet6 fe80::20c:29ff:fee8:8637 prefixlen 64 scopeid 0x20 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 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 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.配置网卡开始网络连接
?
1 2 3 | cd /etc/system/network-scripts/ vi ifcfg-eno16777736 |
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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.重启网络
?
1 | service network restart |
4.再执行ifconfig
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | eno16777736: flags=4163 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 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 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 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.cnblogs.com/lpush/p/5427135.html
内容来源于:https://zhuji.jb51.net/centos/1148.html。
更多资讯:更多资讯
本站发布的【Centos 7开启网卡自动获取IP的详细方法】内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场
如果涉及侵权请尽快告知,我们将会在第一时间立刻删除涉嫌侵权内容,本站原创内容未经允许不得转载,或转载时需注明出处。
Copyright © 2009-2024 56dr.com. All Rights Reserved. 特网科技 版权所有 珠海市特网科技有限公司 粤ICP备16109289号
域名注册服务机构:阿里云计算有限公司(万网) 域名服务机构:烟台帝思普网络科技有限公司(DNSPod) CDN服务:阿里云计算有限公司 百度云 中国互联网举报中心 增值电信业务经营许可证B2
建议您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流浏览器浏览本网站