3

I'm trying to set up Ubuntu Server 16.04 as a router just to figure out how this works and maybe build a home server/router down the line sometime. Problem is, I can't seem to get it to work, not sure if it even accepts the routes I set up.

/etc/network/interfaces:

auto lo 
iface lo inet loopback

auto enp0s3
iface enp0s3  inet static
    address 192.168.1.254
    netmask 255.255.255.0
    gateway 192.168.1.168
    ip route replace default via 192.168.1.1 dev enp0s3

auto enp0s8
iface enp0s8 inet static
    address 3.0.0.254
    ip route replace 192.168.1.0/24 via 192.168.1.254 dev enp0s3
    ip route replace 3.0.0.0/24 via 3.0.0.254 dev enp0s8 

This is probably the eighth or so setup I tried for the routes so it may seem odd. I tried these with "up" before, with "add" instead of "replace" and "||true" as per someone else's previous suggestion here on SE.

Network/VBox setup is as follows: enter image description here The network connection from the router VM to the WAN router in my home LAN is bridged, I can ping to WAN from the router. I can ping to both router interfaces from the host. I can however not ping the host from the router or WAN from the host.

Any suggestions appreciated, thanks.


-Edit-: so I changed the setup a bit as per the suggestions here (thanks for these): enter image description here enter image description here

I've also added a route on my WAN router to point towards the now 192.168.2.0/24 network via 192.168.1.254.

The client (WX, .2.2) can now ping: both LAN-Router interfaces (.2.254 & .1.254), but not the WAN router (.1.1) or into the WAN (8.8.8.8)

The LAN router can ping the WAN router, both its own interfaces and into the WAN, but not to the client (.2.2)

The WAN router can ping both LAN router interfaces, but not the Client.

Windows Firewall on the client is disabled.

I've had a prior setup with a ClearOS VM that worked without configuring the WAN router, but ClearOS wasn't what I had in mind so I tried to use that config for the Ubuntu setup which strangely does not work. VBox config is the same.

As always, any help is appreciated.

  • 3
    The ip addresses of 3.0.0.0/8 belong to General Electric, and shouldn't be used in setups like this (unless you work for GE, and they have actually set those IP's aside for your use). – Henrik Jul 25 '16 at 21:30
  • 1
    On seeing your edits I should have asked you about the type of router you try to configure. NAT (hides the inner network, like your WAN-ROUTER does) or "standard" (makes the inner network visible for hosts in your 192.168.1.0/24 network)? – guntbert Jul 26 '16 at 17:10
  • Since the WAN router already does the NAT, I don't think another internal NAT would make any sense. I really just want a system to put in between the WAN router and the client for monitoring etc. – cmm Jul 26 '16 at 17:24
  • 1
    Thx for confirming what I assumed. I will add to my answer. – guntbert Jul 26 '16 at 20:36
3

The reason why your setup doesn't work is that your WAN-router (let's call it r1) cannot know how to reach the VM behind your Ubuntu router (let's call it r2).

You must (on r1) add a route to the 3.0.0.0/24 network, with the LAN-address of r2 (192.168.1.254) as next hop.

How to do this depends on the software of r2.

As an aside (as has been pointed out in a comment): you should not assign arbitrary network addresses, even if the network is behind a NAT router. Instead use 10.0.0.0/8 or 172.16.0.0/16 - see RFC 1918 for details.

You will have to tell the kernel of r2 to forward IP-packets:

echo 1 | sudo tee >   /proc/sys/net/ipv4/ip_forward

Then make it permanent by uncommenting the following line in /etc/sysctl.conf

net.ipv4.ip_forward = 1
  • Thanks a bunch, it worked. Except for the persistent part, but I found that one here edit /etc/sysctl.conf: uncomment net.ipv4.ip_forward = 1 – cmm Jul 27 '16 at 15:10
  • Thx for reporting back, you are right about "permanent", I obviously copied mindlessly the wrong line from my own blog. – guntbert Jul 27 '16 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.