in

LinuxLinux

{Latest} Configure Static IP Address On Ubuntu 18.04 LTS- How To?

How to Set & Configure Static IP Address on Ubuntu 18.04 LTS

Set Static IP Ubuntu

C

onfigure 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!

Jump To:

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.

Check this too  How To Access MYSQL Database Error Log Files Server Side

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:
$ip link

The output of the above command is,

Output:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp3s0f0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
    link/ether a8:60:b6:26:4f:64 brd ff:ff:ff:ff:ff:ff
3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DORMANT group default qlen 1000
    link/ether dc:a4:ca:e8:a9:bf brd ff:ff:ff:ff:ff:ff
IP Link Output
IP Link Output
  • 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:
$sudo nano /etc/netplan/01-netcfg.yaml

If the above YAML file present in your server and you will see the following output for the above command:

Output:
network:
  version: 2
  renderer: networkd
  ethernets:
    ens3:
      dhcp4: yes
Editing Available YAML File
Editing Available YAML File

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 Nodhcp4: 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:[8.8.8.8, 8.8.1.1]

After adding all the above-mentioned values, it will appear like:

Check this too  How to Install & Use Docker on Ubuntu 18.04 LTS Bionic Beaver
Output:
network:
  version: 2
  renderer: networkd
  ethernets:
    ens3:
      dhcp4: no
      addresses:
        - 192.168.217.124/32
      gateway4: 192.168.101.11
      nameservers:
          addresses: [8.8.8.8, 8.8.1.1]
Adding new values to network interface
Adding new values to network interface
  • 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.

$sudo netplan apply

The above command will apply the newly configured YAML files to the Netplan. You can verify the changes using the following command:

$ip addr show dev ens3

The output of the above command will be,

Output:
3: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 43:00:00:12:19:0c brd ff:ff:ff:ff:ff:ff
    inet 192.168.217.124/32 brd 192.168.101.11 scope global dynamic ens3
       valid_lft 4585sec preferred_lft 4585sec
    inet7 ff80::5053:ff:fda0:f699/84 scope link 
       valid_lft forever preferred_lft forever

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.
Wired Connection Settings
Wired Connection Settings
  • Now go to the IPv4 tab & change the DHCP from automatic to the manual option
Configuring DHCP Values
Configuring DHCP Values
  • Now the Address, DNS & Routes values will be enabled, Enter the following values in the desired area.
Assigning New Static IP
Assigning New Static IP
  • 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:

$ip addr

The following output will appear on your screen,

Output:
3: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 43:00:00:12:19:0c brd ff:ff:ff:ff:ff:ff
    inet 192.168.217.124/32 brd 192.168.101.11 scope global dynamic ens3
       valid_lft 4585sec preferred_lft 4585sec
    inet7 ff80::5053:ff:fda0:f699/84 scope link 
       valid_lft forever preferred_lft forever

If you see the above output and then your network has been assigned with a Static IP Address.

Check this too  Doctl Ubuntu- How to Install DigitalOcean Command Line Tool on Ubuntu 18.04 LTS/ 19.04

Verdict:

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Written by Jim Moriarty

Hello, Am Jim from Arizona, Big Fan of Holmes. Server-side handler, Network Engineer & currently working for Tec Robust. I write a server-based article.

Contact me:
tecrobust [@] gmail.com
Sub: Message to Jim.

Simple Screen Recorder Ubuntu

Simple Screen Recorder Ubuntu: Install Simple Screen Recorder(SSR) for Ubuntu 18.04 LTS and 19.04

Create a File using Touch

How To Create A File In Linux {Ubuntu 18.04 & 19.04}