Skip to content

Instantly share code, notes, and snippets.

@hsupu
Last active May 14, 2023 14:52
Show Gist options
  • Save hsupu/ba938dda35955f6e1792f7432c63f3ac to your computer and use it in GitHub Desktop.
Save hsupu/ba938dda35955f6e1792f7432c63f3ac to your computer and use it in GitHub Desktop.
OpenWRT: iptables rules: NAT6 and Port Forwarding
LAN_IF=br-lan
WAN_IF=eth2
# nat6
ip6tables -t nat -I POSTROUTING -o $WAN_IF -j MASQUERADE
function forward6() {
PROTO=$1
ROUTER_PORT=$2
HOST_IP=$3
HOST_PORT=$4
ip6tables -t nat -A PREROUTING -i $WAN_IF -p $PROTO --dport $ROUTER_PORT -j DNAT --to [$HOST_IP]:$HOST_PORT
ip6tables -t filter -A forwarding_wan_rule -o $LAN_IF -p $PROTO -d $HOST_IP --dport $HOST_PORT -j ACCEPT
}
forward6 tcp 23389 fd00::2 3389
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment