Linux 101 : Adding a static IP address - without using the Network Manager -



We usually put the interfaces that we don't want the Network Manager to handle in the "/etc/networking/interfaces" file.

We also need the change the interface parameter "ifupdown" from managed to unmanaged in the below Network Manager configuration file:

"/etc/NetworkManager/NetworkManager.conf"


We edit the  "/etc/networking/interfaces" to include the below:


We bring down the interface using the below command:


Then, we bring it back up for the changes to take effect:


We could get the above information for our "interfaces" file using the below commands.

To get the IP address and the netmask we want to assign to the interface, we use the below command:
 

To get the default gateway, we use:


To get the DNS information, we check the "/etc/resolv.conf" file. 

We can check if our interface got the static IP address configured in the "interfaces" file, using the below command:


Remark:

For some Linux distributions, we would need to use the below commands instead of the "ifup/ifdown" commands for our changes to take effect:


Comments

Leave as a comment:

Archive