8

我们在两个 AWS 区域和我们的 colo 设施之间有一个带有 Openswan 的 VPN 隧道(使用 AWS 的指南:http ://aws.amazon.com/articles/5472675506466066 )。常规使用工作正常(ssh 等),但我们在所有区域之间的隧道上遇到了一些 MySQL 问题。在 linux 服务器上使用 mysql 命令行客户端并尝试使用 MySQL Connector J 进行连接,它基本上会停止……它似乎打开了连接,但随后卡住了。它没有被拒绝或任何东西,只是挂在那里。

经过初步研究认为这是一个 MTU 问题,但我已经搞砸了很多,没有运气。

与服务器的连接工作正常,我们可以选择要使用的数据库等,但使用 Java 连接器似乎 Java 客户端在进行查询后没有接收任何网络流量。

在 Linux 上的 MySQL 客户端中运行 select 时,我们最多可以得到 2 或 3 行,然后它就会死掉。

话虽如此,我在 AWS 端也有一个单独的 openswan VPN,用于客户端(mac 和 iOS)vpn 连接。一切都通过客户端 VPN 运行得非常好,而且总体上看起来更稳定。我注意到的主要区别是静态连接使用“隧道”作为类型,而客户端使用“传输”,但是当将静态隧道连接切换为传输时,它说有 30 个打开的连接并且不起作用.

我对 OpenSWAN 很陌生,所以希望有人能帮助我指出让静态隧道和客户端 VPN 一样正常工作的正确方向。

和往常一样,这是我的配置文件:

ipsec.conf 用于两个静态隧道服务器:

# basic configuration
config setup
# Debug-logging controls:  "none" for (almost) none, "all" for lots.
# klipsdebug=none
# plutodebug="control parsing"
# For Red Hat Enterprise Linux and Fedora, leave protostack=netkey
protostack=netkey
nat_traversal=yes
virtual_private=
oe=off
# Enable this if you see "failed to find any available worker"
# nhelpers=0

#You may put your configuration (.conf) file in the "/etc/ipsec.d/" and uncomment this.
include /etc/ipsec.d/*.conf

VPC1 到 colo 隧道配置

conn vpc1-to-DT
type=tunnel
authby=secret
left=%defaultroute
leftid=54.213.24.xxx
leftnexthop=%defaultroute
leftsubnet=10.1.4.0/24
right=72.26.103.xxx
rightsubnet=10.1.2.0/23
pfs=yes
auto=start

colo-to-VPC1 隧道配置

conn DT-to-vpc1
type=tunnel
authby=secret
left=%defaultroute
leftid=72.26.103.xxx
leftnexthop=%defaultroute
leftsubnet=10.1.2.0/23
right=54.213.24.xxx
rightsubnet=10.1.4.0/24
pfs=yes
auto=start

客户端 VPN ipsec.conf

# basic configuration

config setup
interfaces=%defaultroute
klipsdebug=none
nat_traversal=yes
nhelpers=0
oe=off
plutodebug=none
plutostderrlog=/var/log/pluto.log
protostack=netkey
virtual_private=%v4:10.1.4.0/24

conn L2TP-PSK
authby=secret
pfs=no
auto=add
keyingtries=3
rekey=no
type=transport
forceencaps=yes
right=%any
rightsubnet=vhost:%any,%priv
rightprotoport=17/0
# Using the magic port of "0" means "any one single port". This is
# a work around required for Apple OSX clients that use a randomly
# high port, but propose "0" instead of their port.
left=%defaultroute
leftprotoport=17/1701
# Apple iOS doesn't send delete notify so we need dead peer detection
# to detect vanishing clients
dpddelay=10
dpdtimeout=90
dpdaction=clear
4

2 回答 2

3

找到了解决方案。需要在两端添加如下IP表规则:

iptables -t mangle -I POSTROUTING -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

这与 1400 的 MTU 一起,我们看起来非常可靠

于 2014-02-20T08:29:32.903 回答
2

我们在从欧盟地区连接到美国的 RDS 实例的服务器上遇到了同样的问题。这似乎是 RDS 实例不响应自动发现 MTU 设置所需的 ICMP 的已知问题。作为一种解决方法,您需要在执行查询的实例上配置一个较小的 MTU。

在连接到 RDS 实例(不是 VPN 隧道实例)的服务器上,运行以下命令以获取 1422 的 MTU 设置(这对我们有用):

sudo ifconfig eth0 mtu 1422
于 2014-04-20T23:24:55.243 回答