大网数据广告活动
服务器运维问答

Routing through a VPN tunnel with Linux machines

· 52CE 我爱测

I have two Linux machines connected with a VPN tunnel: VPN Client <-------> VPN Server 10.74.1.10/24 10.74.1.1/24 Each one has NICs to reach their own networks: ---------> VPN Client <-------------------> VPN Server <------ 10.37…

问题原文

原帖链接 · JonDoe297 · CC BY-SA 3.0

I have two Linux machines connected with a VPN tunnel:

VPN Client <-------> VPN Server
10.74.1.10/24         10.74.1.1/24 

Each one has NICs to reach their own networks:

---------> VPN Client <-------------------> VPN Server <------
10.37.0.205/24   10.74.1.10/24      10.74.1.1/24    10.74.0.1/24

And, of course, I have different Linux computers (Linux A, Linux B, etc.) on each network:

Linux A  <----> VPN Client <-----> VPN Server <----> Linux B

From VPN Client, I can ping to VPN Server and computers like Linux B.

Although, from Linux A, I can ping to both VPN Client machine's interfaces (10.32.0.205 and 10.74.1.10), it turns out I can't ping to VPN Server with address 10.74.1.1 or to any computer on the network B.

I tried to add a new route on Linux A, but I get this:

$ sudo ip route add 10.74.1.1 via 10.74.1.10 dev eth0
RTNETLINK answers: Network is unreachable

$ sudo ip route add 10.74.1.1 via 10.37.0.205 dev eth0
RTNETLINK answers: Network is unreachable

How can I make this works? Maybe configuring something on VPN Client?

EDIT:

The route table on VPN Client is this:

default via 10.37.0.1 dev eth0 
10.37.0.0/24 dev eth0  proto kernel  scope link  src 10.37.0.205 
10.74.0.0/16 via 10.74.1.9 dev tun0 
10.74.1.0/24 via 10.74.1.9 dev tun0 
10.74.1.9 dev tun0  proto kernel  scope link  src 10.74.1.10 
128.0.0.0/1 via 10.74.1.9 dev tun0 

The route table on Linux A:

default via 10.37.1.1 dev eth0 
10.37.1.0/24 dev eth0  proto kernel  scope link  src 10.37.1.217 

Also, I activated IP forwarding on VPN Client

$ sudo sysctl -w net.ipv4.conf.all.forwarding=1

EDIT 2:

Filtering packet on VPN Client:

$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination  

已采纳解答

原帖链接 · SYN · CC BY-SA 3.0

What kind of VPN are you using?

Sounds like your VPN Client should NAT traffic from Linux A to your VPN Server & Linux B. And/or: your Linux B does not have a route back to your VPN Client.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-12-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。