User Tools

Site Tools


linux:networking:static_ip

Static network IP on Ubuntu server

Configuring IP address on Ubuntu server without using any tools other than a text editor

Edit network configuration file

sudo vim /etc/network/interfaces

You fill find configuration something like this

# The primary network interface -- use DHCP to find our address
auto eth0
iface eth0 inet dhcp

Change it to this

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.2
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
dns-nameservers 8.8.8.8 8.8.4.4

And finally restart networking service

sudo /etc/init.d/networking restart

You should be able to ping the host on the new IP address

If you need to add static routes, you can do it here by adding the lines

up route add -net 192.168.10.0 netmask 255.255.255.0 gw 192.168.180.1 dev eth0

And delete them

down route del -net 192.168.10.0 netmask 255.255.255.0 gw 192.168.180.1 dev eth0
linux/networking/static_ip.txt · Last modified: 2017/08/10 11:00 (external edit)