Linux: Setting static IPv4 address using terminal

Once logged into the linux machine, edit /etc/network/interfaces file using your favorite text editor. You would see something like this at the end of the file:

iface eno1 inet dhcp

Change the content of this line to say static instead of dhcp. Also add the other parameters as shown in the below code.

iface eno1 inet static
    address 192.168.1.10
    gateway 192.168.1.1
    netmask 255.255.255.0
    dns-nameservers 192.168.1.1

Additionally to set IPv6 address to auto after the above set of lines as shown below.

iface eno1 inet6 auto

Save and exit the editor. Reboot the system.

Leave a Reply

Your email address will not be published. Required fields are marked *