1 Introduction
This tutorial will demonstrate how to set a static IP address fixed Ubuntu16.04 Server Edition and Ubuntu18.04 Server version of the system.
2. Confirm that you want to modify the card number
Make sure that you want to modify the card number, assuming your server multiple network cards:
ubuntu1804:~$ ip addr
My server configuration is as follows:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:f1:b5:e1 brd ff:ff:ff:ff:ff:ff inet 172.16.87.140/24 brd 172.16.87.255 scope global dynamic ens33 valid_lft 1500sec preferred_lft 1500sec inet6 fe80::20c:29ff:fef1:b5e1/64 scope link valid_lft forever preferred_lft forever
3. Default card configuration file
By default, the network uses DHCP
ubuntu1804: ~ $ cat /etc/netplan/50-cloud-init.yaml profile follows Network: Ethernets: ens33: dhcp4: Yes Addresses: [] Version: 2
4. Set a static IP
Need to modify the configuration file for the following:
ubuntu1804: ~ $ sudo vi /etc/netplan/50-cloud-init.yaml
Assume that the IP address modification is 192.168.1.100, subnet mask, i.e. 24 255.255.255.0, gateway to 192.168.1.1, DNS1: 223.5.5.5, DNS2: 223.6.6.6
network: ethernets: ens33: dhcp4: no addresses: [192.168.1.100/24] optional: true gateway4: 192.168.1.1 nameservers: addresses: [223.5.5.5,223.6.6.6] version: 2
5. Apply the new configuration
ubuntu1804:~$ sudo netplan apply
Use ip addr
check new address
ubuntu1804:~$ ip addr
6. Test Network Connectivity
ubuntu1804:~$ ping 192.168.1.100