ubuntu 18.04 set static ip method

1. Preface##

This tutorial will demonstrate how to set the static fixed IP address of Ubuntu 16.04 Server and Ubuntu 18.04 Server.

2. Confirm the network card number you want to modify##

First confirm the number of the network card you want to modify, assuming your server has 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 network card configuration file##

By default, the network uses DHCP

ubuntu1804:~$ cat /etc/netplan/50-cloud-init.yaml
The content of the configuration file is as follows

network:
 ethernets:
  ens33:
   dhcp4: yes
   addresses:[]

 version:2

4. Set static IP

The configuration file needs to be modified as follows:

ubuntu1804:~$ sudo vi /etc/netplan/50-cloud-init.yaml

Suppose that the IP address is changed to 192.168.1.100, the subnet mask is 24 bits or 255.255.255.0, the gateway is set 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 new configuration##

ubuntu1804:~$ sudo netplan apply 

Use ip addr to check the new address

ubuntu1804:~$ ip addr 

6. Test network connectivity##

ubuntu1804:~$ ping 192.168.1.100

Recommended Posts

ubuntu 18.04 set static ip method
ubuntu16.04 set static ip
Ubuntu18.04, Centos7 static IP
How to set static IP in ubuntu14.04
How to set static IP on Ubuntu 18.04 Server
Summary of CentOS method to set static IP
ubuntu16.0.4 method to set a fixed IP address
How to set static IP on Ubuntu 18.04 Server
Explain how to set static IP on ubuntu14.04
ubuntu20.04 set static ip address (including different versions)
[Quick Start with Ubuntu] Two, Ubuntu set static IP
Set static IP under Centos
Set static IP for CentOS in VMware
ubuntu 14.04 configure 3-wire 3IP
ubuntu set Chinese font
Detailed explanation of static DNS configuration method in Ubuntu
How to set a fixed IP based on Ubuntu 16.04
Configure static IP under CentOS 7
Ubuntu 18.04 install Sogou input method notes
ubuntu20.04 Chinese input method installation steps
ubuntu modify and configure ip address
Windows10 update Ubuntu20.04 LTS method steps
Ubuntu 20.04 Shuangpin input method installation steps
Install Sogou input method on Ubuntu 16
Ubuntu 20.04 CUDA&amp;cuDNN installation method (graphic tutorial)
ubuntu16.04 Sogou input method/Google Pinyin input method