Skip to content

Instantly share code, notes, and snippets.

@kerus1024
Last active Apr 9, 2020
Embed
What would you like to do?
GRE Tunnel on Linux
#!/bin/sh
INTERFACE="gre_yy_zz"
LOCAL_ADDR="72.30.35.9"
REMOTE_ADDR="172.217.161.78"
GRE_CIDR="10.33.0.1/30"
ip link set $INTERFACE down
ip tunnel del $INTERFACE
ip tunnel add $INTERFACE mode gre remote $REMOTE_ADDR local $LOCAL_ADDR ttl 255
ip link set $INTERFACE up
ip addr add $GRE_CIDR dev $INTERFACE
iptables -A INPUT -p gre -s $REMOTE_ADDR -j ACCEPT
iptables -A INPUT -i $INTERFACE -j ACCEPT
iptables -A FORWARD -p gre -j ACCEPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment