Setting up a static IP address on Ubuntu 18.04 is different compared to earlier versions like Ubuntu 14 or Ubuntu 16. In Ubuntu 18.04, the network configuration is managed using a tool called NetPlan, replacing the old /etc/network/interfaces
file used in previous versions.
NetPlan uses YAML configuration files stored in the /etc/netplan/
directory to manage network interfaces. There are two types of renderers for NetPlan:
-
NetworkManager - Commonly used on desktop systems.
-
networkd - Commonly used on servers.
Steps to Configure a Static IP Address Using networkd
Step 1: Identify the Active Network Interface
First, identify the network interface you want to configure. Use the following commands to list all network interfaces:
ifconfig -a
or
ip a
Step 2: Create or Edit a NetPlan Configuration File
If a YAML configuration file doesn’t already exist in the /etc/netplan/
directory, you can generate one using this command:
netplan generate
Step 3: Set a Static IP Address
Open the NetPlan configuration file using a text editor like vim
or nano
. For example:
sudo nano /etc/netplan/01-netcfg.yaml
Add or edit the configuration under the relevant network interface (e.g., eth0
) to look like this:
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
dhcp6: no
addresses:
- 192.168.1.8/24
gateway4: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
Step 4: Apply the Configuration
Save and close the file, then apply the changes using the NetPlan command:
sudo netplan apply
Step 5: Verify the Configuration
Check if the new IP address is active:
ifconfig -a
Test connectivity to ensure the configuration works:
ping 8.8.8.8
Conclusion
You have now successfully configured a static IP address on your Ubuntu 18.04 server using NetPlan. If you have any questions or face issues, feel free to contact us, and our team will assist you.
iDatam Recommended Tutorials
Linux
Solving the 5 Most Common Linux Server Problems
Master the art of Linux server problem solving with this comprehensive guide. Learn how to diagnose and fix common server issues including network problems, disk space management, security vulnerabilities, and performance bottlenecks.
Mysql
How To Create a New User and Grant Permissions in MySQL
Learn how to create a new MySQL user and grant permissions with this comprehensive guide. Understand the essential commands, best practices, and troubleshooting tips for effective user and permission management in MySQL.
Control Panel, Security
Plesk Server Security Tutorial: A Step-by-Step Guide to Secure Your Web Infrastructure
Secure your Plesk server with our in-depth tutorial! Learn step-by-step techniques, from updates and advanced configurations to code-level protections and emergency strategies, to fortify your web infrastructure against potential threats.
Discover iDatam Dedicated Server Locations
iDatam servers are available around the world, providing diverse options for hosting websites. Each region offers unique advantages, making it easier to choose a location that best suits your specific hosting needs.