I have a network, configured within a machine, which is to be used by VMs on that machine. The IP on the physical interface of that machine is I am forwarding internet traffic from IP attached to a VM at to a linux server via default route. The linux server is being used as a gateway here. There is an iproute for on the gateway to forward all traffic destined to to

ip route on machine hosting the VM:

default via dev enp1s0f0 dev tap22-dr2 scope link dev enp1s0f0  proto kernel  scope link  src dev enp3s0f0  proto kernel  scope link  src dev tapd29f98b1-44  scope link 
unreachable  proto bird

Here is my ip route on gateway machine

default via dev eth1 via dev eth1  proto bird dev eth1  proto kernel  scope link  src via dev eth1  proto bird dev eth0  proto kernel  scope link  src

I’m trying to nat all internet traffic coming from to so that VMs on the host machine can get external connectivity. Any help is much appreciated? enter image description here

P.S: this was a simple implementation for external connectivity in OpenStack with Project Calico.


It was an easy fix, though I'm not sure if it is the best solution.

# iptables -t nat -A POSTROUTING -o eth1 -s -j MASQUERADE

Please suggest if there are any better ways.

| 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.