环境:deepin Linux 15.9.2
软件:vmware workstations
情况:没有ip地址,无法联网
root@arnyeksec:~# 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 176 bytes 13944 (13.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 176 bytes 13944 (13.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
首先查看没启用的端口:
root@arnyeksec:~# ifconfig -a
eth0: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 00:0c:29:6f:51:1e txqueuelen 1000 (Ethernet)
RX packets 33 bytes 4639 (4.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 63 bytes 5636 (5.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19 base 0x2000
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 176 bytes 13944 (13.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 176 bytes 13944 (13.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
发现eth0这个端口没有开启,先修改配置文件(添加后两行):
root@arnyeksec:~# vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
然后重启网卡:
root@arnyeksec:~# /etc/init.d/networking restart
[ ok ] Restarting networking (via systemctl): networking.service.
再次查看(已经得到ip地址了):
root@arnyeksec:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.227.133 netmask 255.255.255.0 broadcast 172.16.227.255
inet6 fe80::20c:29ff:fe6f:511e prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:6f:51:1e txqueuelen 1000 (Ethernet)
RX packets 42 bytes 5827 (5.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 78 bytes 7257 (7.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 19 base 0x2000
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 210 bytes 16614 (16.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 210 bytes 16614 (16.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
进行测试:
root@arnyeksec:~# ping baidu.com
PING baidu.com (220.181.57.216) 56(84) bytes of data.
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=1 ttl=128 time=40.5 ms
64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=2 ttl=128 time=41.8 ms
^C
--- baidu.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 40.598/41.208/41.819/0.643 ms
终极解决办法:
进入首选项,重新配置虚拟网络编辑器,重启