How To Assign Static Ip Address In Ubuntu
Ever wondered how your computer knows its way around the internet? It's like having a secret address that only your friends can find. In the world of Ubuntu, this address is c...
Ever wondered how your computer knows its way around the internet? It's like having a secret address that only your friends can find. In the world of Ubuntu, this address is called an IP address, and today, we're going to learn how to make it static. Why? Well, imagine you're throwing a party, and you want everyone to know your address. A static IP is like putting up a big neon sign that never changes.
Why Static IP, You Ask?
Dynamic IP addresses are like renting a house. The landlord can kick you out anytime, and you'll have to move to a new place. This can cause issues if you're running a server or want to access your computer from outside your home network. A static IP is like owning a house. It's always there, and no one can kick you out.
Let's Get Started!
First things first, you need to know your current IP address. Open up a terminal (you can find it in your applications menu) and type:
Must Read
ip addr
Look for the inet line under your network interface (like eth0 or wlan0). That's your current IP address.
Editing the Netplan
Now, we're going to edit the Netplan configuration file. Type this in your terminal:
sudo nano /etc/netplan/01-netcfg.yaml
You'll see a bunch of code. Don't worry, we're just going to add a few lines to make your IP address static.
How To Configure Network Static Ip Address On Ubuntu 1910
Adding the Static IP
Look for the line that says dhcp4: yes. Change it to dhcp4: no. Then, add the following lines under the addresses: section:
- 192.168.1.100/24
Replace 192.168.1.100 with the IP address you want to use. Make sure it's within the range of your network (you can ask your router or internet service provider for this).
Saving and Applying the Changes
Press Ctrl+X, then Y, then Enter to save and exit the file. Now, apply the changes by typing:
sudo netplan apply
How to Assign Static IP Address on Ubuntu 20.04 LTS
Your IP address should now be static. You can check this by typing ip addr again in the terminal.
But Wait, There's More!
You might need to set a static gateway and DNS servers too. To do this, add the following lines to the gateway4: and nameservers: sections:
addresses: [192.168.1.1]
addresses: [8.8.8.8,8.8.4.4]
Replace 192.168.1.1 with your router's IP address, and 8.8.8.8 and 8.8.4.4 with your preferred DNS servers.
Final Thoughts
And there you have it! You've just assigned a static IP address to your Ubuntu machine. It's like giving your computer a permanent home on the internet. Now, go forth and enjoy the benefits of a static IP!