Ubuntu 18.04 network card configuration

ubuntu18.04 server, the new network tool netplan is enabled. Compared with 16.04 and earlier versions, the command line configuration network parameters are quite different from the previous version##

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

Ubuntu 18.04 network card configuration
Network configuration under Ubuntu
CentOS8 network card configuration file
CentOS6/CentOS7 dual network card configuration bonding
ubuntu 18.04 early configuration
CentOS7.0 network configuration
Ubuntu nfs configuration
Ubuntu20.04 configuration notes
Ubuntu 14.04 configuration record
Ubuntu 18.04 LTS configuration network tutorial through Netplan
Ubuntu16.04 configure your own network card information
ubuntu configuration python, Red
Ubuntu configuration development environment
Ubuntu development environment configuration
Ubuntu configure network commands
Centos7.6 dual network card configuration and switching test
023. Ubuntu common personalized configuration
Ubuntu wireless network card problem on Lenovo laptop
Tencent cloud centos 8.0 single network card configuration multiple IP
Ubuntu16.04 installation and simple configuration
Implementation of CentOS8.0 Network Configuration
Ubuntu16.04 install SVN and configuration
Ubuntu PostgreSQL installation and configuration
Ubuntu 18.04 uses elastic network card to configure multiple external network IP
Ubuntu environment variables and ADB configuration
Ubuntu 20.04 best configuration guide for engineers
CentOS7 modify the network card name
Ubuntu16.04 configuration OpenCV3.4.2 and basic use
Detailed examples of Centos6 network configuration
Centos7 change the network card name
Ubuntu 19.1 installation and configuration Chinese environment
Configuration and beautification after Ubuntu installation (1)
Nginx installation and configuration load (ubuntu12.04)
Ubuntu configuration source and installation software
CentOS7 modify network card name and network repair
Ubuntu 20.04 best configuration guide (required for newbies)
JDK environment variable configuration method under ubuntu
Ubuntu17.04 configuration method to replace domestic sources
Ubuntu install PHP and PHP Nginx configuration method
Encountered network configuration traps during centos-ubuntu intercommunication
DLNA/UPnP Server installation and configuration under Ubuntu 12.04