搭建 GRE 隧道

搭建 GRE 隧道

Created
Aug 1, 2021 12:34 PM
Tags
Linux
GRE
Category
Networking
Last Edited
Last updated July 15, 2022
Abstract
Related to Reading List (Column)

出口端

ip tunnel add gre-tunnel mode gre remote $client_ipv4 ttl 128 ip link set gre-tunnel up ip addr add 2402:9e80:2b:b::1/64 dev gre-tunnel sysctl net.ipv6.conf.all.forwarding=1 sysctl net.ipv6.conf.all.proxy_ndp=1
$client_ipv4为入口端IP地址

入口端

ip tunnel add gre-tunnel mode gre remote $server_ipv4 ttl 128 ip link set gre-tunnel up ip addr add 2402:9e80:2b:b::2/64 dev gre-tunnel ip -6 route add default dev gre-tunnel # 会转发所有IPv6流量
$server_ipv4为出口端IP地址

测试

可以通过互ping来测试隧道搭建情况

维护

# 删除 ip link set gre-tunnel down ip tunnel del gre-tunnel # 修改IP ip tunnel change gre-tunnel remote $new_client_ipv4