How to setup network on Ubuntu server 12.04

This article helps to setup network on ubuntu server 12.04 without GUI.
You can also use the same article to setup network on ubuntu desktop 12.04 too.
1. Identifying the interface name
2. Assigning temporary IP
3. DHCP
4. Static
5. Two network cards

Setup network on Ubuntu server 12.04

By default interface names starts with eth. Issue the below command to identify the interface name.krizna@leela:~$ ifconfig | grep eth
eth0 Link encap:Ethernet HWaddr 00:0c:29:cf:a2:c9
Here eth0 is the interface name .

Assigning temporary IP

you can assign temporary ip address, it will last until you restart network service or server.
Step 1 » Assign temporary IP address by typing the below command.krizna@leela:~$ sudo ifconfig eth0 172.27.0.10 netmask 255.255.255.192 upStep 2 » Assign temporary default gateway.
krizna@leela:~$ sudo route add default gw 172.27.0.1 eth0 Step 3 » If you need, you can add DNS server IPs to this file /etc/resolv.conf.nameserver 8.8.8.8
nameserver 4.2.2.1

Assigning DHCP

Step 1 » Add the below lines to /etc/network/interfaces.auto eth0
iface eth0 inet dhcp
Step 2 » Restart network service
krizna@leela:~$ sudo /etc/init.d/networking restart

Assigning Static IP

Step 1 » Add the below lines to /etc/network/interfacesauto eth0
iface eth0 inet static
address 172.27.0.10
netmask 255.255.255.192
gateway 172.27.0.1
broadcast 172.27.0.63
dns-search krizna.com
dns-nameservers 8.8.8.8 4.2.2.2
8.8.8.8 and 4.2.2.2 are the DNS server IPs.
Step 2 » Restart network servicekrizna@leela:~$ sudo /etc/init.d/networking restart

Two network cards

Assigning IPs to two network interfaces.
Step 1 » Identify the interface names .krizna@leela:~$ ifconfig | grep eth
eth0 Link encap:Ethernet HWaddr 00:0c:29:cf:a2:c9
eth1 Link encap:Ethernet HWaddr 00:0c:29:cf:s5:d9
Here eth0 and eth1 are the interfaces .
Step 2 » Add the below lines to /etc/network/interfaces. #interface eth0
auto eth0
iface eth0 inet static
address 172.27.0.10
netmask 255.255.255.192
gateway 172.27.0.1
broadcast 172.27.0.63
dns-search krizna.com
dns-nameservers 8.8.8.8 4.2.2.2
#interface eth1
auto eth1
iface eth1 inet static
address 172.27.1.20
netmask 255.255.255.192
You cannot assign two default gateways .
Step 2 » Restart network servicekrizna@leela:~$ sudo /etc/init.d/networking restart
setup network on Ubuntu server 12.04
External Resources:
Ubuntu network configuration
Interfaces man page

Be the first to comment

Leave a Reply

Your email address will not be published.


*