openvpn的客户端路由方法

Posted by Remilia Scarlet on February 24, 2023

背景

用openvpn搭了一套内网调试的系统,现在有一个client处于一个内网环境,这个内网环境有许多设备需要调试,因此想通过这个client作为router来连接到具体的设备上。

client所处的内网环境ip为10.111.0.0/24,client的openvpn ip为192.168.136.38,用户所在的openvpn网段为192.168.133.0/24,需要进行以下的配置

配置

服务器端

server.conf

route 10.111.0.0 255.255.255.0 192.168.133.1

openvpn server ccd client

iroute 10.111.0.0 255.255.255.0

用户端

sudo ip r add 10.111.0.0/24 via 192.168.133.1 dev tun0

client router

sudo iptables -t nat -A POSTROUTING -s 192.168.133.0/24 -o enp88s0 -j MASQUERADE

iptables持久化保存的方法

sudo apt-get install iptables-persistent
netfilter-persistent save

reference

https://subscription.packtpub.com/book/networking-and-servers/9781783553136/4/ch04lvl1sec38/client-side-routing
https://askubuntu.com/questions/1252275/ubuntu-20-04-cant-persist-the-iptables-configuration
https://blog.csdn.net/u012024577/article/details/50716509
https://forums.openvpn.net/viewtopic.php?t=25464
https://www.cyberciti.biz/faq/how-to-save-iptables-firewall-rules-permanently-on-linux/


| 访问量: