Skip to content

Instantly share code, notes, and snippets.

@wintersolutions
Last active February 2, 2021 03:00
Show Gist options
  • Save wintersolutions/d59234b27538fec1af81e41708fdcfef to your computer and use it in GitHub Desktop.
Save wintersolutions/d59234b27538fec1af81e41708fdcfef to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# outside connections
/usr/sbin/iptables -w -t nat -A PREROUTING -d EXTERNALIP -p tcp --dport 80 -j DNAT --to-destination INGRESSIP:80
/usr/sbin/iptables -w -t nat -A PREROUTING -d EXTERNALIP -p tcp --dport 443 -j DNAT --to-destination INGRESSIP:443
/usr/sbin/iptables -w -t nat -A PREROUTING -d EXTERNALIP -p tcp --dport 6443 -j DNAT --to-destination K8IP:6443
# host
/usr/sbin/iptables -w -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination INGRESSIP:80
/usr/sbin/iptables -w -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to-destination INGRESSIP:443
/usr/sbin/iptables -w -t nat -A OUTPUT -p tcp --dport 6443 -j DNAT --to-destination K8IP:6443
# cluster
/usr/sbin/iptables -w -t nat -A PREROUTING -s LXCIP/16 -d EXTERNALIP -p tcp --dport 80 -j DNAT --to-destination INGRESSIP:80
/usr/sbin/iptables -w -t nat -A PREROUTING -s LXCIP/16 -d EXTERNALIP -p tcp --dport 443 -j DNAT --to-destination INGRESSIP:443
/usr/sbin/iptables -w -t nat -A PREROUTING -s LXCIP/16 -d EXTERNALIP -p tcp --dport 6443 -j DNAT --to-destination K8IP:6443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment