Skip to content

Instantly share code, notes, and snippets.

@victor-abz
Last active September 15, 2022 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victor-abz/23a3021bd50c7ab87d60feb42b392f7f to your computer and use it in GitHub Desktop.
Save victor-abz/23a3021bd50c7ab87d60feb42b392f7f to your computer and use it in GitHub Desktop.
Setup static IP on Ubuntu

for permanent static IP: https://linuxize.com/post/how-to-configure-static-ip-address-on-ubuntu-20-04/

For Temporary:

Step 1: Check network Port

First of all, open Terminal. Enter “ip addr show” command to see the available network adapter whom you want to change the IP address and press execute.

ip addr show

Step 2: Set Static IP

Use sudo ifconfig eth0 X.X.X.X netmask 255.255.255.0 command to change the IP address. You can verify by using “ip addr show” command.

Step 3: Setup DNS

Change DNS Resolver in /etc/resolv.conf first backup // Remove old configs -- better backup it with mv /etc/resolv.conf /etc/resolv.orig

sudo rm /etc/resolv.conf

to gain the root privileges. run

sudo bash

then run sudo echo "nameserver 8.8.8.8" > /etc/resolv.conf where 8.8.8.8 is the address of DNS server.

Step 4: set the Gateway IP

sudo route add default gw X.X.X.X network_device_name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment