Configure Static IP Address on Ubuntu 18.04: Usually, The Router DHCP server will set IP address dynamically. The DHCP can be expand as Dynamic Host Configuration Protocol. Why we need to set the Static IP Address? It will be very useful if you run a media based server on your network & configuring port forwarding!
- Set Static IP address using DHCP
- Set Static IP address using Netplan
- Set Static IP address on Server
- Set Static IP address on Ubuntu Desktop GUI
Set Static IP Address Using DHCP:
Configuring IP Address using DHCP is the best way to set static IP Address. You can assign a static IP Address using Static DHCP on your LAN. Setting a Static IP Address is a feature found in all the router devices which will help you automatically assign the same IP address to a specific network device. Every time, this router device will request the static IP Address from DHCP Server. This process is similar to assigning a static IP to the device unique MAC address.
How To Assign Static IP of your Router:
The Configuration steps of assigning static IP Address of your router completely depend on your Router manufactures. We suggest you read the documentation provided by your Router manufacturer.
Set Static IP address using Netplan:
Netplan is the alternate way to configure the static IP address. Netplan is the default Network Management Tool. Netplan uses the configuration files with YAML syntax. You can replace the previously used network interface which is used to configure the Ubuntu earlier with the newly created network interface configured using YAML. You need to create a new network configured file using YAML Documentations. Netplan will help you create the required network interface file for your choose device or tool. Currently, Netplan supports Network Management & Systemd-networkd renderers. You can access the Network Management in your device using the following command: /etc/network/interfaces, mainly used on Desktop based devices & The Systemd-networkd is used to configure a network interface on servers.
Set Static IP address on Server:
- You need to find the name of the ethernet interface which you want to configure, Use the following command:
The output of the above command is,
- You can access the Netplan files by accessing the directory: /etc/netplan. The Netplan files are stored in .yaml extension.
- The Netplan configured file is usually stored in the name of 01-netcfg.yaml, But the name the configuration file may be different in your system.
- You need to open the YAML file in the nano editor using the below command:
If the above YAML file present in your server and you will see the following output for the above command:
Each YAML file will begin with the Network key and it requires 2 elements. The 2 elements are Version & the Devices. Here, the version of the network key is 2 and the device used here is ethernet. The networkd is the renderer used here. In Ubuntu Server, the networkd is used as the main renderer & this networkd is acting as the backend network renderer.
Now assign a new static IP Address to ens3 interface:
Follow the below steps to assign and configure the new static IP Address to ens3 network interface:
- Initially, the DHCP is in Yes value. Change the DHCP value to No: dhcp4: no
- Now you need to assign the new Static IP Address 192.168.217.124/32 under the value of addresses
- You can add more than one static IP Address to the network interface
- The Static IP Address should be in the IPV4 or IPV6 protocol.
- Now you need to assign the Gateway under the value of gateway:192.168.101.11
- Now you need to specify the default nameserver to your network interface using the value nameserver:[18.104.22.168, 22.214.171.124]
After adding all the above-mentioned values, it will appear like:
- Save the file & exit the file.
Once you saved the file, you need to apply the YAML file changes to the Netplan using the following command.
The above command will apply the newly configured YAML files to the Netplan. You can verify the changes using the following command:
The output of the above command will be,
If you see the above output and then You successfully assigned the Static IP Address of your Ubuntu Server.
Set Static IP address on Ubuntu Desktop GUI:
You can easily set a static IP Adress on Ubuntu Desktop using the GUI method, Open Settings and go to the Network tab.
- After clicking the Network Tab, Go to the Wired Connection Settings option.
- Now go to the IPv4 tab & change the DHCP from automatic to the manual option
- Now the Address, DNS & Routes values will be enabled, Enter the following values in the desired area.
- After providing the required values, click the Apply button to save the new values.
How to check the Newly configured Static IP Address on Ubuntu Desktop:
Once you saved the above changes in the Network Desktop Ubuntu, you can verify the changes that you have made using the following command:
The following output will appear on your screen,
If you see the above output and then your network has been assigned with a Static IP Address.
That’s it, These are the different methods to configure a static IP address on your Ubuntu Server & Ubuntu Desktop. If you have any queries and then feel free to comment on us.