Last active
January 30, 2018 22:02
-
-
Save ajayhn/2239a3e42e95a5feffcc to your computer and use it in GitHub Desktop.
Simple gateway from compute using iptables from vgw1 to vhost0 on linux host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This assumes a single net n1 with 1.1.1.0/24 and vgw1 interface. Can be extended to use a public net and vgw1 on the public net | |
python /opt/contrail/utils/provision_vgw_interface.py --oper create --interface vgw1 --subnets 1.1.1.0/24 --routes 0.0.0.0/0 --vrf default-domain:admin:n1:n1 | |
If you run into error running above script, instead of `import InstanceService` and `import ttypes` use | |
`from contrail_vrouter_api.gen_py.instance_service import InstanceService, ttypes` | |
Now do `ifconfig` and verify `vgw1` is present | |
Using steps from http://www.revsys.com/writings/quicktips/nat.html | |
/sbin/iptables -t nat -A POSTROUTING -o vhost0 -j MASQUERADE | |
/sbin/iptables -A FORWARD -i vhost0 -o vgw1 -m state --state RELATED,ESTABLISHED -j ACCEPT | |
/sbin/iptables -A FORWARD -i vgw1 -o vhost0 -j ACCEPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment