情况:没有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.
————————————————
版权声明:本文为CSDN博主「valecalida」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/valecalida/article/details/88569791