Thursday, April 27, 2023

Setting Static Ip in Ubuntu using Netplan command and netplan file Using...

Setting up a static IP address on Ubuntu is essential for many reasons, such as making sure that your server is always reachable at the same address or allowing you to set up network services with specific IP addresses. Netplan is the default network configuration tool in Ubuntu 18.04 and later versions. In this article, we will show you how to set up a static IP address using Netplan on Ubuntu.
Before we begin, it's important to note that you will need to have sudo privileges on your Ubuntu server to execute the commands in this tutorial.
Step 1 - Determine Network Interface
The first step in setting up a static IP address is to determine the name of your network interface. You can do this by running the following command:
ip addr show
This command will show you all of the network interfaces on your system. Look for the interface that you want to set up a static IP address for, and take note of the interface name. In most cases, the interface name will be "eth0" or "enp0s3".
Step 2 - Configure Netplan
Next, we need to configure Netplan to use a static IP address for our network interface. Netplan configuration files are located in the /etc/netplan/ directory. The default configuration file is called "50-cloud-init.". You can edit this file with your favorite text editor.
sudo nano /etc/netplan/00-<filename>
This command will open the configuration file in the nano text editor. In this file, you will see a configuration block for your network interface. The configuration block will look something like this:
network:
ethernets:
eth0:
dhcp4: true
version: 2
To configure a static IP address, you need to modify the configuration block for your network interface. Replace the "dhcp4: true" line with the following lines:
address: 192.168.1.100/24
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
In this example, we are using a static IP address of 192.168.1.100 with a netmask of 24 bits (255.255.255.0). We also need to set the default gateway address to 192.168.1.1 and specify the DNS server addresses.
Save the file and exit the text editor.
Step 3 - Apply Netplan Configuration
After configuring Netplan, you need to apply the changes to make them effective. To do this, run the following command:
sudo netplan apply
This command will apply the changes to the Netplan configuration file and restart the network service.
Step 4 - Verify Static IP Address
To verify that your Ubuntu server is now using a static IP address, run the following command:
ip addr show
This command will show you the current IP addresses for all of your network interfaces. Look for the interface that you configured, and you should see your static IP address listed.
Conclusion
Setting up a static IP address using Netplan on Ubuntu is a straightforward process that can be done in just a few simple steps. By using a static IP address, you can ensure that your server is always reachable at the same address, making it easier to manage and set up network services. Netplan is a powerful tool that can help you manage your network configuration in Ubuntu, and we hope that this tutorial has helped you get started.

Setting #Static Ip in #Ubuntu using #Netplan #command and #netplan file Using #Command line

#StaticIP #Ubuntu #Netplan #IP #Linux #Unix

No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

Enhancing Unix Proficiency: A Deeper Look at the 'Sleep' Command and Signals

Hashtags: #Unix #SleepCommand #Signals #UnixTutorial #ProcessManagement In the world of Unix commands, there are often tools that, at first ...