Foreword
This article mainly introduces you to the related content of setting fixed IP on Ubuntu 16.04, and share it for your reference and study. I won't say much below, let's take a look at the detailed introduction.
Methods as below:
First explain that this is done on the vm virtual machine under mac
1. Add virtual network card on vm
Open vm's preferences
Enter ifconfig on the local terminal
You can see that this is the virtual network card just joined
2. Set up the virtual machine network adapter
At this time, the virtual machine is randomly allocated from 192.168.219.3 to 192.168.219.254, but we need to configure it in the system itself if we need a fixed allocation.
3. ubuntu system assigns fixed ip
Enter sudo vim /etc/network/interfaces
Add the following content in it (the original content needs to be cleared)
auto ens33
iface ens33 inet static
address 192.168.219.100
netmask 255.255.255.0
gateway 192.168.219.2
dns-nameservers 192.168.219.2
Let's explain in detail below
auto ens33
iface ens33 inet static
# Assigned fixed ip 192.168.219 is determined based on your virtual network card, which has been allocated in the first step
address 192.168.219.100
# Fixed subnet mask
netmask 255.255.255.0
# The default gateway is x.x.x.2 But the vm under windows can be set by yourself, I did not find it on the mac
gateway 192.168.219.2
# The dns input is the same as the gateway
dns-nameservers 192.168.219.2
Only need to restart the network after completion
sudo /etc/init.d/networking restart
Recommended Posts