Skip to content

Instantly share code, notes, and snippets.

@geoangelotti
Created September 26, 2021 17:54
Show Gist options
  • Save geoangelotti/8ca77d0d45aa31ae2f3cbd5af0fb7864 to your computer and use it in GitHub Desktop.
Save geoangelotti/8ca77d0d45aa31ae2f3cbd5af0fb7864 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "Enabling ipv4 forwarding (cleaning old rules)"
# flushing old rules -- USE WITH CARE
iptables --flush
iptables --table nat --flush
# MASQUERADE each request form the inside to the outer world
iptables -t nat -A POSTROUTING -j MASQUERADE
# enable IPv4 packet forwarding in the kernel
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "Master is not operating as router"
#!/bin/bash
ENDPOINT_INTERFACE=$(cat /etc/hosts | grep master | awk '{print $1}')
route add default gw $ENDPOINT_INTERFACE
echo "Gateway now points to $ENDPOINT_INTERFACE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment