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 192.168.56.0 with the gate address being 192.168.56.1, server 192.168.56.10, 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
address 192.168.56.1/24
#dns-nameservers 8.8.8.8

# 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
address 192.168.56.10/24
#dns-nameservers 192.168.56.1
gateway 192.168.56.1

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         192.168.56.1    0.0.0.0         UG    0      0        0 enp0s3
192.168.56.0    *               255.255.255.0   U     0      0        0 enp0s3

On the gate it gives this:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.1     0.0.0.0         UG    0      0        0 enp0s3
192.168.1.0     *               255.255.255.0   U     0      0        0 enp0s3
192.168.56.0    *               255.255.255.0   U     0      0        0 enp0s8

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

 1?: [LOCALHOST]                                         pmtu 1500
 1:  192.168.1.1 (192.168.1.1)                             0.841ms asymm 64 
 1:  192.168.1.1 (192.168.1.1)                             0.487ms asymm 64 
 2:  78.107.145.85 (78.107.145.85)                        58.631ms 
 3:  10.2.251.126 (10.2.251.126)                           1.617ms 
 4:  m9-crs-be14.corbina.net (195.14.62.20)                2.076ms asymm  6 
 5:  m9-br2-be5.corbina.net (195.14.62.49)                 2.589ms

And on the server it returns:

 1?: [LOCALHOST]                                         pmtu 1500
 1:  192.168.56.1 (192.168.56.1)                           0.824ms 
 1:  192.168.56.1 (192.168.56.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 192.168.1.0/24 gw 192.168.1.1 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).

https://wiki.manjaro.org/index.php?title=Forum_Rules#Homework

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 192.168.1.0/24 gw 192.168.1.1 enp0s3 should fix it but it didn't.

192.168.1.1 is your ISP CPE ?
Is 192.168.1.1 aware of 192.168.56.0/24 (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 192.168.56.0/24, 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.