Configuring Two Network Interfaces on Ubuntu Server

Last week i happened to be at one of my clients office and we had a problem with the internet connection. The problem after a long trial and error process was the fact that the server can not use two network interfaces i.e Internal Network(with static IP address) and External Network(with dynamic IP address) at the same time. You could only use one at a time. So i came up with this trick which might save you alot of time trying to accomplish that.

Our goal is to configure the server to have an internal static IP address and also an external dynamic IP address.

The first thing you need to do is to open and edit the network interfaces file. Run this on the terminal to edit with nano or any editor of your choice.

sudo nano /etc/network/interfaces

You will find something like this in it.

auto lo eth0
iface lo inet loopback
iface eth0 inet dynamic

The “lo” network is the loopback local address network interface then the eth0 is the first network interface LAN port on the server.[You can test all other ports to confirm which one is eth0 once it can ping and external address]

Change the file content to the following

auto lo eth0
iface lo inet loopback
 
auto eth0
iface eth0 inet static
address 192.168.1.100 #Change to Your Static IP Address
netmask 255.255.255.0
dns-nameservers 8.8.8.8 8.8.4
 
auto eth1
iface eth1 inet dhcp

Save by pressing CTRL+X on your keyboard then type Y and hit enter to save.

 

Now we’ll just need to restart the networking components:

sudo /etc/init.d/networking restart

 

Try using the local static ip address on another local computer and then try pinging google.com on the server and see the results.

 

Do have a wonderful day 😉

I'm Aminu Bakori, software developer from Nigeria - A country in Africa. Yes Africa is not a country. I founded Payant.ng and some other amazing startups in Nigeria. If i'm not building softwares, you will see me hanging around the geeks at tech conferences. I love reading and teaching about software development.

Leave a reply:

Your email address will not be published.

Site Footer

Sliding Sidebar

About Me

About Me

I'm Aminu Bakori, software developer from Nigeria - A country in Africa. Yes Africa is not a country. I founded Payant.ng and some other amazing startups in Nigeria. If i'm not building softwares, you will see me hanging around the geeks at tech conferences. I love reading and teaching about software development.

Social Profiles