ubuntu16.0.4 Set the method for fixing the ip address
- 2020-10-07 18:58:30
- OfStack
Since Ubuntu is easy to change after a restart, you can fix the ip address in the following way
1. Set the ip address
vi /etc/network/interface
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto ens32
iface ens32 inet static
address 192.168.159.130
netmask 255.255.255.0
gateway 192.168.2.1
2. Set the dns
vi /etc/resolvconf/resolv.conf.d/base
nameserver 8.8.8.8
nameserver 8.8.4.4
3. Refresh the profile
resolvconf -u
4. Restart your Internet service
/etc/init.d/networking restart
If the above command fails to restart the network card, you can manually close the network card, and then open the network card, this is ip has been changed to the fixed ip you set
conclusion