The network card configuration file is: /etc/netplan/50-cloud-init.yaml, the netplan description file uses yaml syntax, and the default is dhcp mode. If you want to configure a static address, you need to modify the content of this file.
Reference: https://netplan.io/
yaml syntax requirements:
1. Case Sensitive
2. Use indentation to indicate hierarchical relationships
3. Tab key is not allowed when indenting, only spaces are allowed.
4. The number of indented spaces is not important, as long as elements of the same level are aligned to the left
5. # Indicates a comment. From this character to the end of the line, it will be ignored by the parser.
Take Tencent Cloud Ubuntu Server 18.04.1 LTS 64-bit image as an example
1. The default configuration is DHCP mode:
root@VM-0-12-ubuntu:~# grep -v ^# /etc/netplan/50-cloud-init.yaml
network:
version:2
ethernets:
eth0:
dhcp4:true
match:
macaddress:52:54:00:d4:51:ad
set-name: eth0
**2. Configure a static IP address: **
root@VM-0-12-ubuntu:~# grep -v ^# /etc/netplan/50-cloud-init.yaml
network:
version:2
ethernets:
eth0:
addresses:[10.10.0.12/24]
gateway4:10.10.0.1
nameservers:
addresses:[183.60.83.19,183.60.82.98]
**3. DNS configuration: **
The DNS configuration in Ubuntu 18.04 has also been updated to systemd-resolve management. You can modify the /etc/resolv.conf configuration file to define DNS, or you can configure it directly in the /etc/netplan/50-cloud-init.yaml file, and you can use systemd- resolve --status View DNS configuration:
root@VM-0-12-ubuntu:~# systemd-resolve --status
Global
DNSSEC NTA:10.in-addr.arpa
16.172. in-addr.arpa
168.192. in-addr.arpa
17.172. in-addr.arpa
18.172. in-addr.arpa
19.172. in-addr.arpa
20.172. in-addr.arpa
21.172. in-addr.arpa
22.172. in-addr.arpa
23.172. in-addr.arpa
24.172. in-addr.arpa
25.172. in-addr.arpa
26.172. in-addr.arpa
27.172. in-addr.arpa
28.172. in-addr.arpa
29.172. in-addr.arpa
30.172. in-addr.arpa
31.172. in-addr.arpa
corp
d.f.ip6.arpa
home
internal
intranet
lan
local
private
test
Link 3(eth0)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers:183.60.83.19183.60.82.98
4. Make the new configuration take effect
root@VM-0-12-ubuntu:~# sudo netplan apply
Recommended Posts