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

OpenVPN - how to stop public traffic routing through vpn server?

· 52CE 我爱测

I have set up an OpenVPN server for access to my work LAN. It appears that all traffic routes through the vpn server when it's connected but I only want LAN traffic to go to it. How can I stop this? Specifically, I want only a si…

问题原文

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

I have set up an OpenVPN server for access to my work LAN. It appears that all traffic routes through the vpn server when it's connected but I only want LAN traffic to go to it. How can I stop this? Specifically, I want only a single website with a public dns which is resolves to a 10.* subnet IP to go through the vpn and everything else to go via my regular ISP.

Here is my server.conf

port 1194

proto udp

dev tun

ca ca.crt
cert my.crt
key my.key
dh dh2048.pem

server 192.168.7.0 255.255.255.0

ifconfig-pool-persist ipp.txt

push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"

keepalive 10 120

comp-lzo

user nobody
group nogroup

persist-key
persist-tun

status openvpn-status.log
verb 3

Here is my ovpn file

client
dev tun
proto udp
remote mydomain.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert my.crt
key my.key
remote-cert-tls server
ping 15
ping-restart 120
route 10.0.0.0 255.0.0.0
route-nopull
comp-lzo
daemon
verb 3
user nobody
group nogroup

Softether works the way i want it to, not routing all traffic through the vpn server. I need to either change the metric for the OpenVPN gateway or mark it as not the default gateway. route

SOFTETHER

default         192.168.1.1     0.0.0.0         UG    600    0        0 wlp1s0
10.0.0.0        10.0.1.1        255.0.0.0       UG    0      0        0 vpn_vpn

OPENVPN

default         192.168.7.5     0.0.0.0         UG    50     0        0 tun0
default         192.168.1.1     0.0.0.0         UG    600    0        0 wlp1s0

The following is from the OpenVPN howto, it indicates that the default is not to direct all traffic through the vpn which is what I want but my configuration at least makes this seem to be the opposite.

By default, when an OpenVPN client is active, only network traffic to and from the OpenVPN server site will pass over the VPN. General web browsing, for example, will be accomplished with direct connections that bypass the VPN.

已采纳解答

原帖链接 · Usman Ali Maan · CC BY-SA 4.0

if you are having server-side(Openvpn server) access normally its under /etc/openvpn/server/server.conf or /etc/openvpn/server.conf comment this configuration it will stop public traffic through OPEVPN

#######push "redirect-gateway def1 bypass-dhcp" 

just put your desire website ip address like you can find desire website ip here

push  "route 96.6.31.216 255.255.255.255"

save this file and restart your openvpn service systemctl restart [email omitted]

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

资料来源与适用范围

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

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

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