Ubuntu server 17.04 & 18.04 it how to set a static IP

Ubuntu 17.04 18.04 system version and the opening of a new web-based tools netplan, for command-line parameters to configure the network has a relatively large difference with the previous version

The previous version is modified / etc / network / interfaces in
the new version /etc/netplan/*.yaml

Check system version command
#lsb_release -a

For example NIC configuration details

Detailed test server NIC configuration file path:
/etc/netplan/01-network-manager-all.yaml
IP information:
IP address: 192.168.0.1
Mask: / 24
Gateway: 192.168.0.254
the DNS: 8.8.8.8 and 8.8.4.4

1. Use vi to edit the configuration file card

We /etc/netplan/01-network-manager-all.yaml

#Let NetworkManager manage all devices on this system
network:
version 2

#renderer: NetworkManager
ethernets:
ens33:
addresses: [192.168.0.1/24]
gateway4: 192.168.0.254
nameservers:
addresses: [8.8.8.8,8.8.4.4]

# Card file comments
, Ethernets:
ens33: NIC name # configuration
addresses: [192.168.0.111/24] # Set the local IP and mask
gateway4: 192.168.0.1 # Set the gateway
nameservers:
Addresses: [8.8.8.8, 8.8.4.4 ] # set DNS

2. The method NIC configuration file in effect
execute commands
#netplan apply
Source: http://www.rakbuluo.com/p18/

Guess you like

Origin blog.csdn.net/xiayudaibas/article/details/91814068