VMware 的linux debian9突然上不了网,在网上找了很久的解决方法,最后找到了一个可行的方法。
一般来说这种问题是网卡引起的。
首先在命令行输入:
user@debian:~$ ifconfig
来查看网卡。如果没找到ifconfig命令,一般是没开启root:
user@debian:~$ su - root
注意小横线-的左边和右边都有一个空格!
查看网卡后,发现只有一个lo,说明的确是未开启网卡,显示如下:
root@debian:~$ 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 8 bytes 480 (480.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8 bytes 480 (480.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
解决方法:
先查看所有网卡:
root@debian:~$ ifconfig -a
ens33: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 00:0c:29:ae:81:89 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 8 bytes 480 (480.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8 bytes 480 (480.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
发现还有一个网卡ens33,显然是它没开启,那就将它开启:
root@debian:~$ ifconfig ens33 up
然后还要分配网卡id:
root@debian:~$ dhclient ens33
这样就能成功上网了。