After setting up the basic environment, you need to set a fixed IP, otherwise the IP will change every time I start, and I will go crazy every time I adjust the IP.
In Ubuntu 17.10, a new command is used to configure a static IP.
For this, we need to modify vim /etc/netplan/01-netcfg.yaml
Let's take a look at the content and format of the file:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version:2
renderer: networkd
ethernets:
ens33:
dhcp4: yes
We can see that the dhcp4 set here is yes. It means dhcp mode.
Okay, now we have to make changes. The following is the modified format:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version:2
renderer: networkd
ethernets:
ens33:
dhcp4: no
dhcp6: no
addresses:[192.168.110.231/24]
gateway4:192.168.110.1
nameservers:
addresses:[114.114.114.114,8.8.8.8]
Now we explain the modified content:
If someone has set the static IP of windows or the static IP of the previous version of ubuntu, you may feel that one thing is missing, yes, it is the subnet mask.
This is /24. It is actually the set subnet mask. Below is the ip corresponding to the prefix, we can use this to set the response.
Prefix size | subnet mask |
---|---|
/24 | 255.255.255.0 |
/25 | 255.255.255.128 |
/26 | 255.255.255.192 |
/27 | 255.255.255.224 |
/28 | 255.255.255.240 |
/29 | 255.255.255.248 |
/30 | 255.255.255.252 |
Well, after we modified the content of the configuration file according to the actual situation. Execute the following command to deploy:
sudo netplan apply
If there is no problem, the solid ip is set successfully. Then we reconfigure our xshell login ip, and just log in again.
Okay, isn't it very simple?
Recommended Posts