我有两台 Linux 服务器。我想使用 GRE 隧道将所有互联网流量从 ClientBox 通过隧道路由到 GatewayBox,这样,对于互联网的其余部分,我的 ClientBox 看起来就是 GatewayBox,这样我就可以将 GatewayBox 的外部 IP 用于所有 ClientBox互联网使用。我已经在它们之间建立了一条 GRE 隧道(代理无法满足我的特定需求)。
我的 GRE 隧道工作了!我可以 ping 两端。
现在我需要配置 GatewayBox 以实际将这些传入连接从 ClientBox 路由到互联网并返回到 ClientBox。所以我运行了以下脚本:
#! /bin/bash
IPTABLES=/sbin/iptables
WANIF='ens3' # servers from this company use ens3 instead of eth0, it seems
LANIF='gre1' # both boxes have the gre tunnel set up as gre1
# enable ip forwarding in the kernel
echo 'Enabling Kernel IP forwarding...'
/bin/echo 1 > /proc/sys/net/ipv4/ip_forward
# flush rules and delete chains …Run Code Online (Sandbox Code Playgroud)