ubuntu 配置静态IP/重启网络报错

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37880968/article/details/81626707

1. 找到文件并作如下修改:
vim /etc/network/interfaces
修改如下部分:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.108.50
gateway 192.168.108.2 #netstat -rn 命令或者  route -n  查看现有的
netmask 255.255.255.0
#network 192.168.0.0
broadcast 192.168.108.255  #广播地址,可以通过ifconfig查看现有的。
配置完成之后重启网络:
sudo /etc/init.d/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.failed!

从新修改配置vim /etc/network/interfaces

auto ens33

iface ens33 inet static

address 192.168.108.50
gateway 192.168.108.2
netmask 255.255.255.0

从新启动:sudo /etc/init.d/networking restart

如果重启网络报错,可能是因为上面写的网卡名称不对导致,默认网卡名不一定是eth0;

亦或是ip等配置错误。

查看ip:ifconfig

如果ip没有变化可以重新启动机器  reboot

猜你喜欢

转载自blog.csdn.net/qq_37880968/article/details/81626707
今日推荐