Ubuntu – Configure Internal and External IP Addresses on Ubuntu 16.04 Server

networkingUbuntu

At the moment I have a host windows server, inside VM's are installed.
One VM is an Ubuntu 16.04 server, which has only external IP and accessible only through internet.

I have added second network interface for this Ubuntu server.
Now how to configure internal IP for these Ubuntu server, in order to access with internal IP if i am connected to LAN?

The eth0 has an external IP and is working fine.

When I add static internal IP to eth1 and restart the network with:

sudo /etc/init.d/networking restart

the following error appears:

Network restart error

Best Answer

You just need to give a new configuration for that interface:

ifconfig -a

will give you the full list of interfaces. Then, check the MAC address to see which one is connected to your LAN network.
Open the configuration file

nano /etc/network/interfaces

and add the needed configuration for your interface. It will look something like this:

auto eth1
iface eth1 inet static
address 192.0.2.100
netmask 255.255.255.0
gateway 192.0.2.1
dns-nameservers 192.0.2.101 

Code explanation
eth1: would be your internal interface. This will deppend on your set up, it could be anything else.
auto: makes the interface wake when starting the server.
iface eth1 inet static: the interface takes a static configuration, change static to dhcp otherwise. If changed to dhcp, everything below that line is not needed.
Note that not all the options are needed in order to configurate the interface.

Related Topic