Setting up Networking from the Command Line
In order to configure or change the networking interfaces attached to your Linux PC, you will need to edit the /etc/network/interfaces file.
.. if you installed Ubuntu server - and you selected auto-LAN configuration at install time - the LAN should have been configured up for you
On a server, if you installed Ubuntu server - and you selected auto-LAN configuration at install time - the LAN should have been configured up for you. If not, you'll need to configure your network from the command line as follows.
Following a vanilla server install, the /etc/network/interfaces file will probably look as follows:
$ more /etc/network/interfaces
# 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
iface lo inet loopback
If your network allocates dynamic IPs, add the following block to the end of the /etc/network/interfaces file:
# Added DHCP ethernet interface (Fred Bloggs, 1st January 2011)
iface eth0 inet dhcp
If your network uses static IPs, append the following block instead to the /etc/network/interfaces file:
# Added static ethernet interface (Fred Bloggs, 1st January 2011)
iface eth0 inet static
address <Static IP Address for the server>
gateway <IP Address of your router>
netmask <Hex mask>
network <IP Address>
broadcast <IP Address>
Save the changes to the file, then run the following command to restart the networking service and apply the changes:
$ /etc/init.d/networking restart