Skip to content

Instantly share code, notes, and snippets.

@Xachman
Created February 17, 2021 14:27
Show Gist options
  • Save Xachman/5689d13cdbf0a686b08917778b78900c to your computer and use it in GitHub Desktop.
Save Xachman/5689d13cdbf0a686b08917778b78900c to your computer and use it in GitHub Desktop.
Create a simple nat using interfaces created by services like Nebula or Zerotier
#!/bin/bash
INTERFACE=ens5
NINTERFACE=nebula1
sudo iptables -t nat -A POSTROUTING -o $INTERFACE -j MASQUERADE
sudo iptables -A FORWARD -i $INTERFACE -o $NINTERFACE -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i $NINTERFACE -o $INTERFACE -j ACCEPT
@Xachman
Copy link
Author

Xachman commented Feb 17, 2021

I use this when it is necessary to gain access to an interface and subnet behind a node on Nebula or Zerotier. This needs to be used in combination with net.ipv4.ip_forward = 1 on linux systems.

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