Ubuntu虚拟机网卡不能正常工作

文章目录


虚拟机安装ubuntu,
网卡配置:
在这里插入图片描述
网卡有时候不能正常启动,执行如下命令:

book@ubuntu:~$ service network-manager restart
book@ubuntu:~$ ifconfig
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 1000  (Local Loopback)
        RX packets 787  bytes 57501 (57.5 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 787  bytes 57501 (57.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

book@ubuntu:~$ ifconfig -a
ens33: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 00:50:56:37:47:5b  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

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 1000  (Local Loopback)
        RX packets 868  bytes 63254 (63.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 868  bytes 63254 (63.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

book@ubuntu:~$ ifconfig ens33
ens33: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 00:50:56:37:47:5b  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

book@ubuntu:~$ sudo ifconfig ens33 up
[sudo] password for book: 
book@ubuntu:~$ ifconfig -a
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::250:56ff:fe37:475b  prefixlen 64  scopeid 0x20<link>
        ether 00:50:56:37:47:5b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 27  bytes 3158 (3.1 KB)
        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 1000  (Local Loopback)
        RX packets 1349  bytes 97407 (97.4 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1349  bytes 97407 (97.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

book@ubuntu:~$ sudo dhclient ens33
book@ubuntu:~$ ifconfig -a
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.233.132  netmask 255.255.255.0  broadcast 192.168.233.255
        inet6 fe80::250:56ff:fe37:475b  prefixlen 64  scopeid 0x20<link>
        ether 00:50:56:37:47:5b  txqueuelen 1000  (Ethernet)
        RX packets 20  bytes 3093 (3.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 46  bytes 5976 (5.9 KB)
        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 1000  (Local Loopback)
        RX packets 1445  bytes 104399 (104.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1445  bytes 104399 (104.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

book@ubuntu:~$ ping www.baidu.com
PING www.a.shifen.com (180.97.34.96) 56(84) bytes of data.
64 bytes from 180.97.34.96 (180.97.34.96): icmp_seq=1 ttl=128 time=15.9 ms
64 bytes from 180.97.34.96 (180.97.34.96): icmp_seq=2 ttl=128 time=15.3 ms
64 bytes from 180.97.34.96 (180.97.34.96): icmp_seq=3 ttl=128 time=15.8 ms
64 bytes from 180.97.34.96 (180.97.34.96): icmp_seq=4 ttl=128 time=16.7 ms
^C
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3007ms
rtt min/avg/max/mdev = 15.319/15.936/16.726/0.505 ms
book@ubuntu:~$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.233.132  netmask 255.255.255.0  broadcast 192.168.233.255
        inet6 fe80::250:56ff:fe37:475b  prefixlen 64  scopeid 0x20<link>
        ether 00:50:56:37:47:5b  txqueuelen 1000  (Ethernet)
        RX packets 45  bytes 6006 (6.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 73  bytes 8498 (8.4 KB)
        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 1000  (Local Loopback)
        RX packets 1465  bytes 106141 (106.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1465  bytes 106141 (106.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

book@ubuntu:~$ 

版本:ubuntu 20.04

可以总结一下命令:

$ service network-manager restart                  #启动网卡服务
$ ifconfig ens33                                   #查看网口配置项信息;
$ sudo ifconfig ens33 up                           #启动网口
$ sudo dhclient ens33                              #重新获取网口IP;

之前的错误原因是:
IPv6不能使用;

 inet6 fe80::250:56ff:fe37:475b

通过刷新,保留了IPv6,并获取了IPv4;

 inet 192.168.233.132 
 inet6 fe80::250:56ff:fe37:475b
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值