Categories: UbuntuUbuntu 12.04

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

External Resources:
Ubuntu network configuration
Interfaces man page

Disqus Comments Loading...
Share
Published by
krizna

Recent Posts

How to install Visual Studio Code on ubuntu 20.04

Visual Studio Code is a popular code editor which is lightweight and cross platform application.…

4 years ago

How to install MySQL workbench on ubuntu 20.04

MySQL workbench is a GUI tool for managing MySQL database system. It is used by…

4 years ago

How to install Android Studio on ubuntu 20.04

Android Studio is a popular development software used especially for developing android applications. It is…

4 years ago

How to install google chrome on ubuntu 20.04

Google chrome is a most popular web browser developed by google. It was developed to…

4 years ago

How to install Zoom on ubuntu 20.04

Zoom is a popular video conferencing software. It is commonly used for conducting online meetings,…

4 years ago

How to install TeamViewer on ubuntu 20.04

TeamViewer is a popular application for desktop sharing and remote control. It is available for…

4 years ago