Configuring Network Settings in Ubuntu Server: Basics and Troubleshooting
Introduction to Network Configuration on Ubuntu Server
Configuring network settings for a server is essential for successful operation. This article covers basic network configuration using Netplan and troubleshooting steps to resolve common networking issues.
Basic Network Configuration
1. Checking your interface information
Use the following command to check the status of available network interfaces:
1user@machine:~$ ip addr
In our example output it shows two network interfaces, the system loopback lo
and our enp0s3
interface.
11: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
2 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
3 inet 127.0.0.1/8 scope host lo
4 valid_lft forever preferred_lft forever
5 inet6 ::1/128 scope host noprefixroute
6 valid_lft forever preferred_lft forever
72: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
8 link/ether 00:1b:21:00:00:00 brd ff:ff:ff:ff:ff:ff
9 inet 192.168.1.10/24 brd 192.168.1.255 scope global dynamic noprefixroute enp0s3
10 valid_lft 6077sec preferred_lft 6077sec
11 inet6 fe80::1c68:8197:5a52:f1b2/64 scope link noprefixroute
12 valid_lft forever preferred_lft forever
2. Finding your Netplan Configuration
Your Netplan configuration will be located in the /etc/netplan/
directory. The filename may differ, however this can be checked using the following command:
1user@machine:~$ ls /etc/netplan/
When you have found it, open it in your favourite text editor but remember to use sudo
as this file will need root privileges.
1user@machine:~$ sudo nano /etc/netplan/01-netcfg.yaml
3. Examples of a Netplan Configuration
Here is an example that configures DHCP for IPv4 on the enp0s3
network interface.
1network:
2 version: 2
3 renderer: networkd
4 ethernets:
5 enp0s3:
6 dhcp4: true
Here is an example that configures a static IPv4 address, subnet, default route, and two DNS servers on the enp0s3
network interface.
1network:
2 version: 2
3 renderer: networkd
4 ethernets:
5 enp0s3:
6 dhcp4: false
7 addresses:
8 - 192.168.1.100/24
9 routes:
10 - to: default
11 via: 192.168.1.1
12 nameservers:
13 addresses:
14 - 8.8.8.8
15 - 8.8.4.4
4. Apply the changes
To apply the changes without rebooting just run the following:
1user@machine:~$ sudo netplan apply
If the configuration does not work as intended you can get more information with the following:
1user@machine:~$ sudo netplan --debug apply
Troubleshooting Networking Issues
1. Checking Network Connectivity
To verify network connectivity you can use the ping
command. If the following is successful, it indicates that your system is able to connect out:
1user@machine:~$ ping 8.8.8.8
However if the next command is successful, it indicates that your system is able to connect out as well as being able to resolve DNS queries.
1user@machine:~$ ping google.com
Conclusion
Configuring network settings in Ubuntu Server is essential for connectivity and accessing resources on a network. By following these basic configuration steps and troubleshooting techniques outlined in this article, you can effectively set up and troubleshoot basic network connections on your Ubuntu Server system.