Skip to content

Instantly share code, notes, and snippets.

@tompreston
Created November 4, 2016 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tompreston/d5053c5553ce02a2b4627892fe7d266c to your computer and use it in GitHub Desktop.
Save tompreston/d5053c5553ce02a2b4627892fe7d266c to your computer and use it in GitHub Desktop.
#!/bin/bash
# Enable IP Forwarding
# Run this, then route packets on device with:
#
# ip route add default via THIS_DEVICE_IP
#
OUT_IFACE=enp0s25
IN_IFACE=enx00249b1ad5b2
IPTABLES=/sbin/iptables
# setup iptables
$IPTABLES --flush -t nat
$IPTABLES --table nat --append POSTROUTING --out-interface $OUT_IFACE -j MASQUERADE
$IPTABLES --append FORWARD --in-interface $IN_IFACE -j ACCEPT
# turn on ip forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment