Ubuntu 18.04 LTS is different from the previous version of Ubuntu. It uses a brand new Netplan to manage network configuration, so if we need to modify the network settings of Ubuntu 18.04 LTS, we need to configure Netplan and make it effective. This article explains in detail the configuration process of Netplan, including the configuration of a single network card with multiple IP addresses, a single network card with multiple gateways, multiple network cards with multiple IPs, static IP, DHCP, etc.
This article first explains the entire process, and then focuses on the modification of the configuration file.
1、 View configuration file
ls /etc/netplan/
You can see the configuration file name.
2、 Open the configuration file
vim /etc/netplan/*.yaml
3、 Modify the configuration file, this is described in detail below
4、 Test profile
sudo netplan try
If there is no problem, you can continue to apply.
5、 Application configuration file
sudo netplan apply
6、 Restart network service
sudo systemctl restart system-networkd
If it is the desktop version:
sudo systemctl restart network-manager
7、 Verify IP address
ip a
At this point, the entire process is complete. More reference: https://vitux.com/how-to-configure-networking-with-netplan-on-ubuntu/
1、 Use DHCP:
network:
version:2
renderer: networkd
ethernets:
enp3s0:
dhcp4:true
2、 Use static IP:
network:
version:2
renderer: networkd
ethernets:
enp3s0:
addresses:-10.10.10.2/24
gateway4:10.10.10.1
nameservers:
search:[mydomain, otherdomain]
addresses:[10.10.10.1,1.1.1.1]
3、 Multiple network ports DHCP:
network:
version:2
ethernets:
enred:
dhcp4: yes
dhcp4-overrides:
route-metric:100
engreen:
dhcp4: yes
dhcp4-overrides:
route-metric:200
4、 Connect to open WiFi (no password):
network:
version:2
wifis:
wl0:
access-points:
opennetwork:{}
dhcp4: yes
5、 Connect to WPA encrypted WiFi:
network:
version:2
renderer: networkd
wifis:
wlp2s0b1:
dhcp4: no
dhcp6: no
addresses:[192.168.0.21/24]
gateway4:192.168.0.1
nameservers:
addresses:[192.168.0.1,8.8.8.8]
access-points:"network_ssid_name":
password:"**********"
6、 Use multiple IP addresses (same network segment) on a single network card:
network:
version:2
renderer: networkd
ethernets:
enp3s0:
addresses:-10.100.1.38/24-10.100.1.39/24
gateway4:10.100.1.1
7、 Use multiple IP addresses of different network segments on a single network card:
network:
version:2
renderer: networkd
ethernets:
enp3s0:
addresses:-9.0.0.9/24-10.0.0.10/24-11.0.0.11/24
# gateway4: # unset, since we configure routes below
routes:- to:0.0.0.0/0
via:9.0.0.1
metric:100- to:0.0.0.0/0
via:10.0.0.1
metric:100- to:0.0.0.0/0
via:11.0.0.1
metric:100
The above are some of the most common configurations. I believe everyone can understand them for reference. If you don’t understand, I suggest you don’t toss, so as not to crash the network, it is more reliable to seek professional help.
For more configuration, refer to: https://netplan.io/examples, and "Ubuntu 18.04 LTS using Netplan configuration network tutorial".
Recommended Posts