I get this error while configuring a network in Virtual Box with Linux.

I have 2 gateways ( and that are connected to 2 hosts. The first first host has address and is connected to the gw via 10.0.10 1 while the other has 10 0 20 100 and is connected to the other gw via

The gw are connected via host only network adapters. I have configured the hosts as gw with ip forward.

I make and default gateway for the two hosts. Then my idea was to route add (from net netmask gw but I got that error. Can not understand why. Do you have any solution?

Hope it is better

  • The gateway has to be on the same network as the client. If you're on, the gateway to get to 10.0.20.x has to have a 192.168.10.x address.
    – Barmar
    Feb 2, 2017 at 22:15
  • But I can ping from one gw to the other.
    – Rapax
    Feb 3, 2017 at 4:35
  • That's because you have a route to the other gateway. But Linux doesn't do recursive route lookup -- it won't use a gateway to get to a gateway. You have to tell it the first gateway to send to.
    – Barmar
    Feb 3, 2017 at 5:30
  • Ok, so from 10.0.10.x i have to add net 10.0.20.x through
    – Rapax
    Feb 3, 2017 at 5:46
  • 1
    It would help if you showed a diagram of how everything is connected.
    – Barmar
    Feb 3, 2017 at 16:40

1 Answer 1


The tunnel between the gateways needs to be a common network.

One way would be to set its network mask to, so that all 192.168.x.x addresses are on the same network.

If you want to keep the network mask, both gateways need to have 192.168.10.x (or 192.168.20.x) addresses.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .