kali linux 网卡配置出错 RTNETLINK answers: File exists
程序员文章站
2024-02-14 16:09:46
...
虚拟机使用kali linux 通过桥接方式和主机通信,需要保证ip 在同一网段,子网掩码,默认网关,DNS服务器地址相同
1)修改网卡配置文件:
vi /etc/network/interfaces
在这些语句下面
auto lo
iface lo inet loopback
添加如下内容:注意和主机的ip地址同一网段,默认网关一致
auto eth0
iface eth0 inet static
address xxx.xxx.xxx.xxx
netmask 255.255.255.0
gateway xxx.xxx.xxx.xxx
2)DNS服务器也要保证一致
vi /etc/resolv.conf
添加
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx
3)重启网卡
/etc/init.d/networking restart
也可以使用如下命令:
service networking restart
出现如下错误
[....] Restarting networking (via systemctl): networking.serviceJob for networking.service failed because the control process exited with error code.
See "systemctl status networking.service" and "journalctl -xe" for details.
查看信息如下
4月 29 15:28:06 kali systemd[1]: Starting Raise network interfaces...
4月 29 15:28:06 kali ifup[3457]: RTNETLINK answers: File exists
4月 29 15:28:06 kali ifup[3457]: ifup: failed to bring up eth0
4月 29 15:28:06 kali systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
4月 29 15:28:06 kali systemd[1]: networking.service: Failed with result 'exit-code'.
4月 29 15:28:06 kali systemd[1]: Failed to start Raise network interfaces.
查看网络的解决方法:
ip addr flush dev eth0
重新启动:
/etc/init.d/networking restart
输出如下:
[ ok ] Restarting networking (via systemctl): networking.service.
结束。