Ubuntu18.04 configuration card online

2019/10/29, Ubuntu Server 18.04

Summary: Ubuntu Server 18.04 netplan adopted as a network configuration management, change IP network connection to it

Modify the network card configuration

The first to use ip ato view the current NIC Name:

You can see our network card eth0 is the name to remember this, configure the network card to use to back
a man named lo configuration, is the loopback interface loopback

Enter the card configuration directory

cd /etc/netplan/

View directory file, there is a yaml file name suffix is the current network configuration file, called me here-Cloud-init.yaml 50:

vi open the file for editing:

sudo vi 50-cloud-init.yaml

Described below are two NIC configuration, one is automatically assigned using DHCP IP, is to use a static fixed IP

Automatically assigns IP

In ethernets node added eth0 (ip a name card used earlier seen), the child node dhcp4: true to:

network:
    ethernets:
        eth0:
            dhcp4: true
    version: 2

Note dhcp4 behind a colon followed by a space! ! !

Save and exit, use the command netplan application settings:

sudo netplan apply

Revisit IP, found that configuration works:

Static fixed IP

In ethernets node, configured as follows:

network:
    ethernets:
        eth0:
            dhcp4: no
            addresses: [192.168.137.13/24]
            gateway4: 192.168.137.1
            nameservers:
                addresses: [192.168.137.1]
    version: 2

Note points:
1. The need to have a space after the colon!
2. The first addresses the address, / 24 is the subnet mask information
3.gateway4 gateway
addresses in the DNS address is 4.nameservers

save and exit, use the command netplan application settings:

sudo netplan apply

Revisit IP, found that configuration works:

Guess you like

Origin www.cnblogs.com/kasnti/p/11759030.html