linux网卡自动激活

之前在家linux是可以正常上网的,但是今天到学校发现打开centOS 7之后执行ping www.baidu.com之后发现出现下面的情况:

[root@hhh ~]# ping www.baidu.com
ping: www.baidu.com: 未知的名称或服务

这说明网络无法连通,我就觉得奇怪,然后执行以下命令发现网卡没有启动(为什么在家里用的好好的,一到学校就不会自动启动网卡了,Amazing!)

[root@hhh ~]# ifconfig   //结果只显示lo和virbro接口

这时我执行:

[root@hhh ~]# service network restart

重启网卡之后执行ifconfig出现网卡ens33;

[root@markpain ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.88.222  netmask 255.255.255.0  broadcast 192.168.88.255
        inet6 fe80::4a68:883b:ba08:a5bc  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:21:b8:4b  txqueuelen 1000  (Ethernet)
        RX packets 1948  bytes 2499869 (2.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1161  bytes 85056 (83.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<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 640  bytes 50520 (49.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 640  bytes 50520 (49.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:1e:fb:d8  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

在我的centOS 7中我之前已经在/etc/sysconfig/network-scripts/ifcfg-ens33中将onboot设置为yes.

百度之后发现只要在/etc/rc.d/rc.local中加入以下语句即可:

ifup ens33  //有的是 ifup eth0
//或者 ifconfig ens33 up 或ifconfig eth0 up

其中ens33和eth0是电脑上网卡的名称。

之后重启系统,网卡就会自动激活。


end
MrBread 2017-02-14 祝大家情人节快乐!

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值