I have a routing problem with IP forwarding on my ubuntu server.

On my ubuntu server (an old laptop) I have VirtualBox installed with a number of virtual machines. Each VM has it's virtual NIC bridged to the physical wlan0 adaptor on the server, and if set to use DHCP they will happily get an IP address from my home wireless router. So bridging seems to be working fine.

The wireless router operates on the subnet

Some VMs have static IPs set up on different subnets which are awkward to change due to the applications running on them. I have two VM subnets:

I thought I could get them all happily talking by giving my host laptop an IP address on each subnet, pointing the VMs to the appropriate IP as their gateway and then enable IP forwarding on the host. So the host has the following IPs assigned to wlan0:

With this set up, VMs on the subnet can ping those on the subnet and vice versa. The host happily IP forwards between those two subnets. The VMs on those subnets can also ping the server on

However, none of the VMs on either subnet or can ping the wireless router on

I guess the config on the host is lacking something, but i can't see what the difference is between VMs in each subnet pinging each other, and VMs on either subnet pinging the router on a third subnet - other than that it's a physical device - i'm still just asking the host to IP forward from one subnet to another. What's the difference that i'm missing?!

Appreciate any help offered.


Edit - diagram below for clarity. It shows attempted pings between virtual machines, the host and the router. routing diagram

  • The post can get a bit difficult to follow, I advise posting a drawing of your networks/setup, even if a photo of one done by hand. – Rui F Ribeiro Mar 10 '16 at 14:46
  • yeah, i guess so - diagram added. – Ken Knowles Mar 11 '16 at 9:23
  • Thanks. Host is bridging VM traffic, right? Have you defined net.ipv4.conf.all.rp_filter=0 ? – Rui F Ribeiro Mar 11 '16 at 9:32
  • Yeah VMs are all bridged to the host wlan0 interface. Thanks for the suggestion. I had not defined that system variable but I have now. Unfortunately i hasn't enabled me to ping the router from a VM. – Ken Knowles Mar 11 '16 at 11:09

You need to have rp_filter for a bridging host to accept outputting packets that are not own of their own range of IP local IP addresses.


As for routing, the problem is that the router does not know the 172.19.40.x network, and while the packet reaches the router, the answer goes by the default gateway (i.e. an unknown network, instead of coming back).

You need to define in the router the route (e.g.) gw

Doing that, the answer will return to your host.

On second thought, this might not be the right answer, and as it it bridging, you will have to give the router a secondary IP of the network.

| improve this answer | |
  • When pinging the router from a VM, the error is 'no route to host' rather than response timeout, which make me think even wth rp_filter disabled the request isn't reaching the router. I agree adding another IP to the router would be the ideal solution, unfortunately my cheap ISP supplied router doesn't support multiple IP addresses so I was trying to get around it. I could just add a proper router VM with multiple vNICs to solve the issue but I was just curious why using the host to forward isn't working. – Ken Knowles Mar 11 '16 at 13:55
  • If you are doing bridging you have to have a router that forwards packets between networks, or routing or NAT in multiple points. – Rui F Ribeiro Mar 11 '16 at 13:57
  • (the alternative is doing routing+NAT in the Host) – Rui F Ribeiro Mar 11 '16 at 14:09

you need to add a few routes on your wireless router.

  • via
  • via

Go into your wireless router manual and find how to do static routes. I had this same issue and the router did not know how to send traffic back to the server since they are on different subnets. You need to create that path back from your router to each subnet.

| improve this answer | |

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.