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

OpenVPN - client as a gateway for other clients

· 52CE 我爱测

I have the following structure: What I'd like to achieve is essentially route ALL traffic from laptop clients (and any possible future client) through MacOS OpenVPN client in internal network. I know the easiest thing would be to…

问题原文

原帖链接 · Michal Tokarz · CC BY-SA 4.0

I have the following structure:

What I'd like to achieve is essentially route ALL traffic from laptop clients (and any possible future client) through MacOS OpenVPN client in internal network.

I know the easiest thing would be to run OpenVPN server on MacOS internal server however it is behind proxy and firewall and can't be accessed from the outside (ssh tunneling is not an option in my case) - this is why I have such a strange structure.

How clients and server should be configured to achieve this?

社区高分解答

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

it is possible to route a subnet that is accessible only via another openVPN client using ccd scripts

For example in your case, you would have to add on your AWS server configuration resembling this

Let's assume that 10.80.0.1 is the IP of your AWS VPN Gateway (The VPN address, not external IP), and 10.0.2.0/24 is the subnet that you wish to route via MacOS server

in file /etc/openvpn/ccd/macos_vpn_commonname

iroute 10.0.2.0 255.255.255.0 push "route 10.0.2.0 255.255.255.0 10.80.0.1" route 10.0.2.0 255.255.255.0 10.80.0.1"

You also need a line In your OpenVPN server main config file on the AWS server
client-config-dir /etc/openvpn/ccd

What it does it tells OpenVPN server upon the macos_vpn_commonname client connection, that the subnet 10.0.2.0 /24 is reachable via that client and enables routing via that tunnel. As far as I was testing there is no other way to do it, even manually routing the traffic via previously created tunnel will not work.

That would cover routing the subnet through a MacOS server. If you need to redirect ALL traffic through it then let me know and I will try to help you further using iprule / iproute on the AWS OpenVPN server and redirect-gateway directive, as I'm not sure if OpenVPN is prepared for such scenario with internal mechanisms.

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

资料来源与适用范围

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

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

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