DHCP to a Static IP Address Ubuntu

Andy's photo
·Aug 7, 2021·

1 min read

Changing DHCP without a GUI will require some effort, but that’s classic linux, right?

Ok, lets do it !
First, open interface file using your fav editor. I'm going to use nano.

$ sudo nano /etc/networking/interfaces

at opened file, change with the following lines:

auto eth0 iface eth0 inet static address netmask network broadcast gateway dns-nameservers #dns google

Then edit file resolv.conf

$ sudo nano /etc/resolv.conf

and type this value (I use dns google)

nameserver nameserver

Now, delete dhcp-client service with command:

$ sudo apt-get remove dhcp-client

And restart NIC

$ sudo /etc/init.d/networking restart

Share this