嗨,我试着做以下几件事(Ips就是例子):
沟通应如下所示:
50.50.50.1 (default adapter) -> 50.50.40.1 (tun0 adapter) -> 50.50.30.1
在网关计算机的路由表中可以配置这样的东西吗?
我用的是ubuntu 16.04
谢谢你的回答
发布于 2018-04-17 11:57:21
我找到了解决办法。我可以使用NAT表:
# the ip of node which is in MSD network. This can be for example edge node
IP_OF_SOURCE_NODE=50.50.50.1
# ip of destination database where we want to connect (do not forget on port)
IP_OF_DESTINATION_NODE=50.50.30.1:22
# ip address of VPN network adapter
IP_OF_VPN_NETWORK_ADAPTER=50.50.51.1
# Need to change the destination ip to database ip for the packets incoming from default network from specific source (for example dge node)
iptables -t nat -A PREROUTING -i ens5 -p tcp -s ${IP_OF_SOURCE_NODE} --dport 22 -j DNAT --to-destination ${IP_OF_DESTINATION_DATABASE}
# Need to change the source ip to inet address of vpn network address for packets leaving VPN network adapter
iptables -t nat -A POSTROUTING -o tun0 -p tcp -s ${IP_OF_SOURCE_NODE} --dport 22 -j SNAT --to-source ${IP_OF_VPN_NETWORK_ADAPTER}之后,我成功地连接到节点50.50.30.1,从50.50.50.1到50.50.40.1。
https://askubuntu.com/questions/1025506
复制相似问题