news
Serverspace Technologies in the UAE: Launch of Falconcloud
WB
April 20, 2020
Updated August 1, 2023

Configuring the network interface in Ubuntu 18.04

Ubuntu

Using another OS?

Select the desired version or distribution.

Network interface configuration in Ubuntu 18.04 via netplan



    Network configuration in Ubuntu 18.04 has been changed quite a lot compared to previous versions of Ubuntu. The configuration file /etc/network/interfaces has not gone away, but it has become insignificant, now it contains only the text that files related to network settings are now located in the /etc/netplan directory:

    Screenshot 1: Configuring the network interface in Ubuntu 18.04

    Let's look at this:

    ls /etc/netplan

    Screenshot 2: content of the directory /etc/netplan

    Then take a look at the file structure:

    cat /etc/netplan/50-cloud-init.yaml

    Screenshot 3: checking content of the directory /etc/netplan

    The netplan settings is described in YAML (Yet Another Markup Language). Let's look inside:

    • network — a "marker" word that means the start of a logical block of the settings;
    • ethernets — this parameter means that the Ethernet network will be configured further;
    • enp0s3 — the name of the interface to be setup. Yours will probably look different. All network interfaces present on the computer will be displayed after the following command:
    ifconfig -a
    • addresses — an IP addresses that the interface has. Addresses should be set in CIDR format. The first IP is written as at the screenshot, and when more than one address is required, they are placed in square brackets, a comma is placed between the addresses;
    • gateway4 — IPv4 gateway;
    • nameservers — this "marker" indicates that the section below contains the names or IP-addresses of servers that processes DNS queries;
    • addresses — names (or addresses) of hosts that resolve DNS names to IP addresses. If necessary, they may be written in square brackets as described above, one address is separated from another by a comma;
    • version — YAML language version.

    To activate new settings, run this:

    netplan apply

    Network configuration without netplan

    Before the setup, I advice you to clarify which interfaces are really present in the system:

    ifconfig -a

    Screenshot 4: get a list of available interfaces Ubuntu 18.04

    In the screenshot above, you can see that there are two interfaces without assigned IP's present, cause the machine is waiting for settings from the DHCP server. In a situation where there is no such DHCP-server in the network segment, you should assign the IP manually. So, change the config-file so that it looks like the one shown in the picture:

    sudo nano /etc/network/interfaces

    Screenshot 6: customization of DHCP Ubuntu 18.04

    Let's talk about the parameters:

    • auto enp0s3 - this instruction "tells" the computer to automatically start the network after reboot;
    • iface enp0s3 inet static - parameter indicating that the network address should be set manually;
    • address 10.10.2.6 - assigned IPv4 address;
    • netmask 255.255.255.0 - subnet mask
    • gateway 10.10.2.1 - IPv4 gateway
    • dns-nameservers 8.8.8.8 - hosts that process DNS requests.

    To confirm the changes, you should run this:

    sudo /etc/init.d/networking restart

    Screenshot 7: applying settings and restarting network Ubuntu 18.04

    After the service restart, the computer should be available via assigned IP address. If not, reboot the server entirely, it will help.

    Conclusion

    This article describes two ways to configure a network in Ubuntu 18.04, both with and without netplan.



    Vote:
    4 out of 5
    Аverage rating : 4.6
    Rated by: 18
    1101 CT Amsterdam The Netherlands, Herikerbergweg 292
    +31 20 262-58-98
    700 300
    ITGLOBAL.COM NL
    700 300
    We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
    Use of Cookies and Privacy Policy.