Stuck in configuring Ubuntu as a gateway

I need to configure an Ubuntu 16 installation as a gateway (it's a kind of a hometask) but I have run into a hitch. Sorry for asking it here, but I mainly use Manjaro and I have a suspicion that the solution will be as simple as route add ...

So, I have several VMs with Ubuntu 16, one of them is supposed to be a gateway, it has 2 interfaces: a bridged one, via which it is connected to the Internet, and a host-only adapter, which is for its LAN with other VMs.

One other VM is supposed to be a client, and one, a server, they both have only one (host-only) adapter.

LAN address is with the gate address being, server, and dynamically assigned range for clients (well, there is only one actually).

The gate has the following /etc/network/interfaces:

# The LAN network interface
auto enp0s8
iface enp0s8 inet static

# The WAN network interface
auto enp0s3
iface enp0s3 inet dhcp
dns-search corp56.un

The server has this:

# The LAN network interface
auto enp0s3
iface enp0s3 inet static

I can ping each other with their 192.168.56.X addresses, and the gate has the connection to the Internet, but I can't connect to the Internet from either server or client (I'm concerned with the server at this point).

route executed on the server gives this:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         UG    0      0        0 enp0s3    *        U     0      0        0 enp0s3

On the gate it gives this:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         UG    0      0        0 enp0s3     *        U     0      0        0 enp0s3    *        U     0      0        0 enp0s8

Also, on the gate tracepath -b returns some responding addresses from ISP:

 1?: [LOCALHOST]                                         pmtu 1500
 1: (                             0.841ms asymm 64 
 1: (                             0.487ms asymm 64 
 2: (                        58.631ms 
 3: (                           1.617ms 
 4: (                2.076ms asymm  6 
 5: (                 2.589ms

And on the server it returns:

 1?: [LOCALHOST]                                         pmtu 1500
 1: (                           0.824ms 
 1: (                           0.690ms 
 2:  no reply

Then just "no-replies". So, am I right in thinking that I need to add some route? I have tried route add -net gw enp0s3 on the gate VM, but it did not change anything.

Oh, and I forgot to tell that I did set sysctl -w net.ipv4.ip_forward=1 on the gate and that ip tables are empty (for now).

This is a solved problem, you just have to follow a "how to" on the web.

First, I said it's a "kind of a hometask". Which means that I assigned it to me myself :slight_smile: What we did in class was set up DHCP, DNS, and a couple other servers on preconfigured VMs. I just decided to see if I can recreate this configuration (VMs) myself.

Second, it seems to me that it is not a solved problem, or at least that there are some things that are taken for granted in all the howtos that I've seen. Because I did read up on it before asking this question, but all the guides that I'v seen describe how to make the settings that I have given above: /etc/network/interfaces and enabling ip forwarding. Both of these things I've done but something is still missing.

Well, there is a third thing, configuring DHCP server on the gate, but that I didn't mention because the server VM has static configuration, and as I see from tracepath, the packets do get to the gate, but do not go furhter, that's why I think that I need to add some route there. But that I can't find how to do it, that's why I'm asking for advice. It seemd to me that route add -net gw enp0s3 should fix it but it didn't. is your ISP CPE ?
Is aware of (a route to reach it)?

Yes (if I understand CPE correctly, the English is not my native language), it is the router through which my desktop (on which the VMs are running) is connected to my ISP.

It is not aware of, it receives its settings from the ISP via DHCP.

You need to turn on NAT in iptables. Easy way is use UFW. Many articles on Ubuntu as Router.

1 Like

Ah, thanks! This helped!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.