Ubuntu Network Configuration Command Line

July 6, 2021 . 1 MIN READ

https://help.ubuntu.com/community/NetworkConfigurationCommandLine/Automatic

sudo vi /etc/network/interfaces

## To configure a dynamic IP address

auto eth0

iface eth0 inet dhcp

 

## Or configure a static IP

auto eth0

iface eth0 inet static

address 192.168.1.14

gateway 192.168.1.1

netmask 255.255.255.0

network 192.168.1.0

broadcast 192.168.1.255

For these settings to take effect you need to restart your networking services.

sudo /etc/init.d/networking restart

 

Setting up a second IP address or Virtual IP address

If you need to set up a second ip address you need to edit the /etc/network/interfaces.

sudo vi /etc/network/interfacesauto eth0:1iface eth0:1 inet static  address 192.168.1.24  netmask 255.255.255.0  network 192.168.1.1  broadcast 192.168.1.255  gateway 192.168.1.1

For these new settings to take effect you need to restart networking services using the following command

sudo /etc/init.d/networking restart

 

Leave a Reply

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