91
Setting a static IP in Ubuntu involves editing the netplan configuration file using the nano text editor. Here’s a brief summary of the steps:
- Open the terminal and run the following command to install the nano text editor if it’s not already installed:
sudo apt install nano
- Next, navigate to the netplan configuration directory by running:
cd /etc/netplan
- Use the nano text editor to open the netplan configuration file. For example, if the file is named “01-netcfg.yaml”, run:
sudo nano 01-netcfg.yaml
- Within the file, locate the network interface you want to set a static IP for. It will look similar to this:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
- Replace the line
dhcp4: yes
with the following lines to set a static IP:
addresses: [192.168.1.100/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
Make sure to adjust the IP address, subnet mask, gateway, and DNS servers according to your network configuration.
- Save the changes by pressing “Ctrl + O”, then exit nano by pressing “Ctrl + X”.
- To apply the changes, run the following command in the terminal:
sudo netplan apply
After following these steps, your Ubuntu system should now have a static IP address configured. Keep in mind that any mistakes in the netplan configuration file can cause network connectivity issues, so it’s important to double-check your changes before applying them.
Refer – https://www.freecodecamp.org/news/setting-a-static-ip-in-ubuntu-linux-ip-address-tutorial/