How to configure a Static IP Address on Ubuntu Server 18.04 LTS
Please share with your friends...
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

This post is a quick how-to for configuring a Static IP Address on Ubuntu Server 18.04 LTS.

The method of configuring a Static IP Address on Ubuntu Server has changed with the release of version 18.04 Bionic Beaver. Static address settings are no longer made through the /etc/network/interfaces file, but are instead made through the /etc/netplan/50-cloud-init.yaml file.
  1. Use the nano text editor to modify the /etc/dhcpcd.conf file with the following command:
    sudo nano /etc/netplan/50-cloud-init.yaml

    The nano text editor will open and display the contents of the /etc/netplan/50-cloud-init.yaml file.

    # This file is generated from information provided by
    # the datasource.  Changes to it will not persist across an instance.
    # To disable cloud-init's network configuration capabilities, write a file
    # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
    # network: {config: disabled}
    network:
        ethernets:
            eth0:
                addresses: []
                dhcp4: true
                optional: true
        version: 2

    Note that the eth0: entry in the example above refers to the network interface name, which may be differ from system to system.

  2. Make the following modifications to the file:
    # This file is generated from information provided by
    # the datasource.  Changes to it will not persist across an instance.
    # To disable cloud-init's network configuration capabilities, write a file
    # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
    # network: {config: disabled}
    network:
        version: 2
        renderer: networkd
        ethernets:
            eth0:
                dhcp4: false
                addresses: [192.168.0.10/24]
                gateway4: 192.168.0.1
                nameservers:
                   addresses: [8.8.8.8,8.8.4.4]

    Adjust the values to suit your network environment.

  3. Press Ctrl + X to exit nano, press Y to save changes, and press Enter to confirm the existing filename.
  4. Apply the updated netplan configuration, using the following command:
    sudo netplan apply

    If you were connected remotely via SSH, you will now need to reconnect using the new static IP address!

  5. Show the updated interface configuration, using the following command:
    ifconfig

    The command produces output similar to the following:

    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.0.10  netmask 255.255.255.0  broadcast 192.168.0.255
            inet6 fe80::82c3:4e6:21f:5763  prefixlen 64  scopeid 0x20
            ether 00:15:5d:43:6a:39  txqueuelen 1000  (Ethernet)
            RX packets 11245  bytes 1779964 (1.7 MB)
            RX errors 0  dropped 219  overruns 0  frame 0
            TX packets 1588  bytes 199076 (199.0 KB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    Your Ubuntu Server is now configured to use a static IP address.


Linux® is a registered trademark of Linus Torvalds. Canonical, Ubuntu and the Ubuntu logo are trademarks of Canonical Ltd.

Please share with your friends...
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share
Tagged on:                     

Leave a Reply