将ubuntu网络设置为静态地址

将ubuntu网络设置为静态地址:(将iface ens33 inet dhcp改成iface ens33 inet static)

xg@Ubuntu:/var/lib/NetworkManager$ sudo vi /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

# The primary network interface
#auto ens33
#iface ens33 inet dhcp

auto ens33
iface ens33 inet static
address 192.168.1.253
gateway 192.168.1.1
netmask 255.255.255.0

 

重启:

xg@Ubuntu:/var/lib/NetworkManager$ sudo /etc/init.d/networking restart
查看:

xg@Ubuntu:/var/lib/NetworkManager$ ifconfig
ens33 Link encap:Ethernet HWaddr 00:0c:29:81:8e:d0
inet addr:192.168.1.141 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe81:8ed0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:222535 errors:0 dropped:81 overruns:0 frame:0
TX packets:77757 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:91262137 (91.2 MB) TX bytes:62721297 (62.7 MB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:476 errors:0 dropped:0 overruns:0 frame:0
TX packets:476 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:33616 (33.6 KB) TX bytes:33616 (33.6 KB)

 

结果没变:然后各种百度,google,据説要这样?

sudo vi /etc/NetworkManager/NetworkManager.conf

打开该文件,将“managed=false”修改为“managed=true”。

重启network manager:

sudo service network-manager restart

即可解决问题。

 

但我发现我虚拟机并未装NetworkManager,那么安装吧:

sudo apt-get install network-manager
安装完后,修改后,重启服务:

sudo service network-manager restart
sudo service networking restart

问题依旧,查看IP地址:依然是141,然后,重启系统,问题解决

 

1 Comments
  1. 棒棒滴!!!

Leave a Reply