0

I have a VM (HOST A) on a Hypervisor in a network that cannot see the outside world. I have another VM (HOST B) on another Hypervisor that can see the outside world. I can ping HOST B from HOST A. I want to route traffic from HOST A to HOST B so I can reach the outside.

HOST A example IP: 172.17.175.5

HOST B example IP: 10.130.128.242

On HOST B I have done

sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o ethx -j MASQUERADE

on HOST A I tried doing

ip route del default  
ip route add default via IP_of_HOSTA

but I get RTNETLINK answers network is unreachable

run traceroute on HOST A for 10.130.128.242 shows

 1  172.17.175.1 (172.17.175.1)  0.453 ms  0.877 ms  0.870 ms
 2  172.16.1.1 (172.16.1.1)  0.861 ms  0.853 ms  0.844 ms
 3  la.la.la.net (172.16.255.254)  2.567 ms  2.627 ms  4.439 ms
 4  10.0.40.105 (10.0.40.105)  1.921 ms  2.122 ms  2.253 ms
 5  10.250.247.4 (10.250.247.4)  1.465 ms  1.495 ms  1.765 ms
 6  blah.blah.blah.net (10.130.128.242)  0.811 ms  0.787 ms  2.412 ms

is it possible to do this with only editing configs on the two VMs? If so how?

the VMs are set up in bridge mode if that matters.

UPDATE: after adding

ip route add 10.130.128.242/32 via 172.17.120.1

ip route shows

10.130.128.242 via 172.17.120.1 dev ens3
172.17.120.0/26 dev ens3 proto kernel scope link src 172.17.120.5

1 Answer 1

0

You will need to add a route to Host B via the original default gateway on Host A.

ip route add IPOFHOSTB/32 via original_gateway

Only then change the default.

2
  • thanks, but I am still getting a "RTNETLINK answers Network is unreachable" when I try to add it as default. I updated my question with what my route table looks like now
    – scott
    Aug 10, 2017 at 14:27
  • Do you get that when pinging the gateway or something else? From the route table, you seem to have forgotten to add the default route after adding a route to the default gateway which is in another network. Aug 11, 2017 at 20:18

You must log in to answer this question.

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