Proper network configuration is crucial for stable and secure server operations. In this guide, we will walk you through the process of configuring both IPv4 and IPv6 static IP addresses using Netplan on Ubuntu. We will also show you how to identify your network interfaces before applying configurations.
Step 1: Find Network Interface Names
Before configuring static IPs, you must determine the name of your network interfaces. Use the following command:
ip link show
Alternatively, you can use:
ls /sys/class/net/
Common interface names include eth0
, ens160
or enp0s3
. Note the correct interface name for configuration.
Step 2: Configure Netplan with Static IP Addresses
Netplan configurations are stored in the /etc/netplan/
directory. Open or create a YAML file in that directory, such as 01-netcfg.yaml
.
sudo nano /etc/netplan/01-netcfg.yaml
Below is a generic example to configure both IPv4 and IPv6 static IP addresses:
network:
version: 2
ethernets:
eth0:
dhcp4: false
dhcp6: false
addresses:
- 192.168.1.100/24
- 2001:db8::1/64
routes:
- to: default
via: 192.168.1.1
- to: "::/0"
via: "2001:db8::1"
on-link: true
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
- 2001:4860:4860::8888
- 2001:4860:4860::8844
Replace eth0
with your actual network interface name. Update IP addresses, gateway routes, and nameservers based on your network environment.
Step 3: Apply the Netplan Configuration
After saving the configuration file, apply the settings with the following command:
sudo netplan apply
If you want to verify the configuration before applying, use:
sudo netplan try
Step 4: Verify Network Configuration
Run the following commands to confirm that your static IP addresses are active:
ip addr show
ip route show
Final Notes
Using Netplan simplifies the management of complex network configurations. Whether you are configuring a cloud server, a dedicated server, or a local workstation, static IP addressing ensures stability and easier remote management.
For reliable and secure server hosting solutions, visit XeonBD.