GRE 隧道不工作

GRE 隧道不工作

我一直在寻找解决方案,但一无所获。我想知道是否可以通过 OpenVPN 连接转发 80 等端口?我正在使用预装 OpenVPN Debian 8 发行版的 OVH VPS。客户端端口到服务器或类似的东西。任何帮助都将不胜感激。

编辑:这是一张糟糕的图表,但总比没有好! 点击查看图表 在图上,webserver 位于 server1 上我的错

将其更改为 GRE 隧道。我像这样在两端设置了隧道,但我无法使用它。在服务器 1 上执行的命令:

ip tunnel add gre1 mode gre remote 66.xxx.xx.xx local 158.xx.xxx.xxx ttl 255
ip link set gre1 up
ip addr add 10.0.0.1/24 dev gre1

在服务器 2 上完成的命令:

ip tunnel add gre1 mode gre remote 158.xx.xxx.xxx local 66.xxx.xx.xx ttl 255
ip link set gre1 up
ip addr add 10.0.0.2/24 dev gre1

我无法从服务器 1 ping 10.0.0.2,但是显然可以从服务器 2 ping 10.0.0.2。

服务器 1 ip 地址输出:

root@server1:~# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group defaul                                                       t qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP gr                                                       oup default qlen 1000
link/ether fa:16:3e:17:34:30 brd ff:ff:ff:ff:ff:ff
inet 158.xx.xxx.xxx/32 brd 158.69.202.194 scope global ens3
   valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe17:3430/64 scope link
   valid_lft forever preferred_lft forever
3: gre0@NONE: <NOARP> mtu 1476 qdisc noop state DOWN group default qlen 1
link/gre 0.0.0.0 brd 0.0.0.0
4: gretap0@NONE: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN group defa                                                       ult qlen 1000
link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
7: gre1@NONE: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1476 qdisc noqueue state UNKNO                                                       WN group default qlen 1
link/gre 158.xx.xxx.xxx peer 66.xxx.xx.xx
inet 10.0.0.1/24 scope global gre1
   valid_lft forever preferred_lft forever
inet6 fe80::200:5efe:9e45:cac2/64 scope link
   valid_lft forever preferred_lft forever

IP 路由服务器 1:

root@server1:~# ip route
default via 158.xx.xxx.1 dev ens3
10.0.0.0/24 dev gre1  proto kernel  scope link  src 10.0.0.1
158.xx.xxx.1 dev ens3  scope link

服务器2的IP地址:

root@server2:~# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
   valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
   valid_lft forever preferred_lft forever
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether d8:9d:67:d3:71:09 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.30/24 brd 192.168.1.255 scope global dynamic enp0s25
   valid_lft 73469sec preferred_lft 73469sec
inet6 fe80::3062:291f:ccf6:26aa/64 scope link
   valid_lft forever preferred_lft forever
3: wlo1: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 00:24:d7:e8:73:30 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.36/24 brd 192.168.1.255 scope global dynamic wlo1
   valid_lft 73461sec preferred_lft 73461sec
4: gre0@NONE: <NOARP> mtu 1476 qdisc noop state DOWN group default qlen 1
link/gre 0.0.0.0 brd 0.0.0.0
5: gretap0@NONE: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN group default qlen 1000
link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
11: gre1@NONE: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1476 qdisc noqueue state UNKNOWN group default qlen 1
link/gre 66.xxx.xx.xx peer 158.xx.xxx.xxx
inet 10.0.0.2/24 scope global gre1
   valid_lft forever preferred_lft forever
inet6 fe80::200:5efe:42d3:132c/64 scope link
   valid_lft forever preferred_lft forever

IP 路由服务器 2:

root@server2:~# ip route
default via 192.168.1.1 dev enp0s25 proto static metric 100
10.0.0.0/24 dev gre1 proto kernel scope link src 10.0.0.2
169.254.0.0/16 dev gre1 scope link metric 1000
192.168.1.0/24 dev enp0s25 proto kernel scope link src 192.168.1.30 metric 100

答案1

听起来您想在服务器 1 和服务器 2 之间建立 VPN 连接/隧道。然后在服务器 1 上使用反向代理(nginx/apache/haproxy/varnish/...)通过隧道将所有请求转发到服务器 2。

相关内容