Skip to content

Instantly share code, notes, and snippets.

@midnight-wonderer
Last active August 24, 2019 11:35
Show Gist options
  • Save midnight-wonderer/e81552be41a5a23d9d60f982abc8d7b5 to your computer and use it in GitHub Desktop.
Save midnight-wonderer/e81552be41a5a23d9d60f982abc8d7b5 to your computer and use it in GitHub Desktop.
Creating Linux NAT router
SHELL:=/usr/bin/env bash
DEFAULT_INTERFACE=$(shell /sbin/route | grep default | grep -Eo "[a-z0-9]+$$")
VPC_CIDR=10.0.0.0/16
forward-traffic:
/sbin/iptables -t nat -A POSTROUTING -o $(DEFAULT_INTERFACE) -s $(VPC_CIDR) -j MASQUERADE
@midnight-wonderer
Copy link
Author

midnight-wonderer commented Aug 24, 2019

@reboot make -f /root/nat/Makefile forward-traffic 2>&1 >> /dev/null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment