是的我知道。 啊!
我有一个小办公室,我们正在努力减less我们的networking开支。
由于客户审计要求,我们运行自己的邮件服务器,并希望保持这种方式。 为此,我们需要两个静态的IP地址。 到目前为止,我们已经为我们的办公networking提供了与我们的ISP的“StaticIP商业计划书”。 这项服务一直不够好。
我想把办公室连接切换成我能find的最便宜/最快的dynamic计划; 很多的select。 但是这意味着放弃我们的邮件服务器的静态IP。
我们也有一个简单的网站云中的小VPS。 它没有足够的资源来托pipe我们的邮件服务器,但是有2个静态IP。
我想build立一个“隧道”,使用VPS的静态IP作为我们的邮件服务器的公开可见的IP地址,并且连接到实际的邮件服务器 – 现在在我们的LAN上,使用dynamicIPv4后面的NAT。
阅读完毕后,我想这样做的方法是使用OpenVPN将使用本地OpenVPN客户端的办公室邮件服务器连接到在VPS上运行的OpenVPN服务器 – 全部由静态IPv6提供隧道经纪人(HE.net), 独立于我们的ISP。
我设法得到了IPv6隧道设置。 和OpenVPN服务器和客户端。 我甚至可以通过IPv6在两者之间build立连接
在这一点上,我被困住了 – 我完全丧失了路由(我想!)需要获得VPS上的外部IPv4地址来通话和监听邮件服务器正在监听的内部IPv4地址IPv6链路。
我在网上发现了一些文章,但是他们似乎都说“只是在客户端和服务器之间build立一个OpenVPN连接”,根本就不详细说明 – 不pipe怎样:-(然后对于获取地址和入站和出站stream量的映射完全没有任何说法。
VPS和Office路由器上也有一个防火墙。 我甚至没有开始考虑我需要打开通过VPN的IMAP和SMTPstream量…
有人可以共享一个文档,或者帮助你在这里做什么,以及如何做?
作为参考,我的networking布局是:
------------------------------------ | VPS Server | | eth0: | | IPv4 = 172.16.10.100 | | IPv6 = 2100:...:0444::100 | | tun1: | | IPv6 = 2199:...:1 | ------------------------------------ | | | | | --------------------------------- | | eth1: | | | IPv4 = 172.16.10.63 | | | IPv6 = 2100:...:0444:2 | | | | | | Server-side Gateway | | | | | | eth0: (PUBLIC IPs) | | | IPv4 = xyz63 | | | IPv6 = 2100:...:0444:1 | | --------------------------------- | | | | | ---------------- VPN | Internet/WAN | | ---------------- | | | | | --------------------------------- | | eth0: | | | IPv4 = abc24 | | | IPv6 = 2600:...:0123:1 | | | | | | Client-side Gateway | | | | | | eth1: | | | IPv4 = 192.168.1.24 | | | IPv6 = 2600:...:0123:2 | | --------------------------------- | | ------------------------------------ | |-----------------------------| MailServer | | | | eth0: | | | | IPv4 = 192.168.1.199 | | | | IPv6 = 2600:...:0123:199 | | | ------------------------------------ ------------------------------------ | Client | | eth0: | | IPv4 = 192.168.1.100 | | IPv6 = 2600:...:0123:100 | | tun1: | | IPv6 = 2699:...:1 | ------------------------------------
而具体的目标是让来自以VPS上的“公共IP”为目标的Internet / WAN的消息stream量
IPv4 = xyz63 port 25 IPv6 = 2100:...:0444:1 port 25
立即被redirect到收听的“MailServer”,并且,
来自邮件服务器的通信量被正确地路由到“公共IP”,似乎来自这些外部IP。
我已经能够根据我在网上find的例子以及在OpenVPN的食谱中得到这个想法的一部分,但是一旦我添加了IPv6隧道,我还没有运行客户端路由,推路线等都build立了这样的交通stream量。
如果您要在VPS服务器上运行TCP代理,您应该能够避开VPN并直接通过IPv6从VPS到邮件服务器。
Socat将在Linux上诀窍:
socat -d -d -lmlocal2 \ TCP4-LISTEN:25,bind=myaddr1,su=nobody,fork,reuseaddr \ TCP6:mail.domain.local:80,bind=myaddr2
或在Windows上netsh:
netsh interface portproxy add v4tov6 listenport=25 connectaddress=mail.domain.local connectport=25 protocol=tcp
要么将连接到VPS服务器的IPv4地址连接到邮件服务器的IPv6地址。
如果发送者具有IPv6访问权限,这也会带来跳过VPS的额外好处。
如果你不想使用OpenVPN而没有端口转发function,那么你需要做如下的事情来获得stream量:
假设IPv4公网地址为1.2.3.2和1.2.3.3,网关为1.2.3.1。 假设VPS站点的[2001:abcd:1 ::]的IPv6公用地址假设客户端站点的IPv6公用地址为[2001:abcd:2 ::]假设VPS边缘的IPv4隧道地址为10.1.100.1,10.1 .100.2为客户端
注意:这是一些伪代码,但会非常接近ciscoconfiguration。 我手边没有相应的iptables和OpenVPNconfiguration,但应该很容易翻译。
VPS网关:
! gateway acts as a router ip routing ipv6 unicast-routing ! interfaces interface outside ip address 1.2.3.2 255.255.255.248 interface inside ip address 172.16.10.63 255.255.255.0 ipv6 address 2001:abcd:1:1::1 /64 interface tunnel6 ipv6 address 2001:abcd:1::1 tunnel source 1.2.3.2 ! Routing table: ! send traffic for the client net via the openvpn p2p link ip route 192.168.1.0 255.255.255.0 172.16.10.100 ip route 0.0.0.0 0.0.0.0 1.2.3.1 ipv6 route ::0/0 2001:abcd:1::2 ! NAT Table: ! nat the mailserver static (outside,inside) 1.2.3.4 192.168.1.199 netmask 255.255.255.255
VPS服务器:
! vps server acts as a v4 router ip routing ! interfaces interface inside ip address 172.16.10.100 ipv6 address 2001:abcd:1:1::100 /64 interface tun0 tunnel source 2001:abcd:1:1::100 tunnel destination 2001:abcd:2:1::100 ip address 10.1.100.1 255.255.255.252 ! Routing table: ip route 192.168.1.0 255.255.255.0 10.1.100.2 ip route 0.0.0.0 0.0.0.0 172.16.10.63 ipv6 route ::0/0 2001:abcd:1:1::1
客户端路由器
! gateway acts as a router ip routing ipv6 unicast-routing ! interfaces interface outside ip address from dhcp interface inside ip address 192.168.1.24 255.255.255.0 ipv6 address 2001:abcd:2:1::1 /64 interface tunnel6 ipv6 address 2001:abcd:2::1 ! routing ip route 172.16.10.0 255.255.255.0 192.168.1.100 ipv6 route ::0/0 2001:abcd:2::2
客户边缘:
! client edge acts as a v4 router ip routing interface inside ip address 192.168.1.100 255.255.255.0 ipv6 address 2001:abcd:2:1::100 /64 interface tunnel0 tunnel source 2001:abcd:2:1::100 tunnel destination 2001:abcd:1:1::100 ip address 10.1.100.2 255.255.255.252 ip route 172.16.10.0 255.255.255.0 10.1.100.1 ! use pbr to send internet traffic from the mailserver over the vpn access-list 1 permit 192.168.1.199 route-map pbr-mailserver-vpn permit 10 match ip address 1 set ip default next-hop 10.1.100.1 route-map pbr-mailserver-vpn permit 20 set ip default next-hop 192.168.1.24
邮件服务器:
interface inside ip address 192.168.1.199 255.255.255.0 ! since our default traffic must be natted to the secondary VPS IP, forward over ! client edge to vpn ip route 0.0.0.0 0.0.0.0 192.168.1.100
注意:如果您的边缘路由器支持GRE或其他封装隧道协议,您可以跳过服务器并在路由器上执行隧道。 但请记住,客户端路由器必须能够根据源地址执行策略路由,以便将来自邮件服务器的stream量返回到隧道上。
我将再次强调,这样做从v4到v6的端口转发提供了很less的好处,并增加了一个荒谬的点复杂性。 它还会引入难以追踪的问题,如非对称路由,NAT和多层隧道(这将使MTU降低大约400字节)。
为什么不让办公室服务器在IPv6上执行入站邮件(SMTP),并使用VPS作为双堆栈的后备? 支持IPv6的发送者可以直接发送到办公室服务器,其他人可以发送到VPS,然后通过IPv6将其中继到办公室。