By default, Ubuntu uses DHCP in order to get an IP address. If you need a static IP instead, you need to update your interface configuration. This is done in file /etc/network/interfaces
By default, the contents of this file will probably look similar to this:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet dhcp
Most likely, your main interface will be eth0 (or wlan0 for wireless). So if we want to assign a static IP to eth0, something as follows may work:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.48
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
You would have to update this file as root user:
sudo vi /etc/network/interfaces
After those changes are saved you either need to:
1) restart your server
sudo shutdown -r now
or
2) restart the interface
sudo /etc/init.d/networking restart