0

So I have one VPS (based on openvz) with VPN (openvpn) up and running. I'm connecting to this setup with laptop (archlinux) and everything seems to be working. Let's say that vps's ip is 192.0.2.4. I can connect to it and see 192.0.2.4 as my ip when I ask some other server. So traffic is going through vpn.

However, I'm still accessing mail and ssh via direct connection and not via vpn. I think I know why that is (default route to the 192.0.2.4 to prevent loops in routing etc.) and in most use-cases this would be good enough. But not for me. One of the reasons for vpn is to circumvent port blocking in my workplace (cannot send mails via 587). And I cannot do it like this.

So, how to redirect traffic even to the 192.0.2.4 via the vpn? I was thinking about routing everything to the 192.0.2.4 which is not on port X (my vpn port) but not sure how to do this or if it's even possible.

1

Your VPS must have more than one IP address. The simplest solution is to connect to a different IP address. For example if the public IP of the VPS is 192.0.2.4 and the VPN connection is using 172.17.2.0/24 with the server on 172.17.2.1 and client on 172.17.2.2, then you can let the client connect to the SMTP server using 172.17.2.1 rather than 192.0.2.4.

One drawback of this approach is, that using an internal IP will only work while the VPN connection is active. And putting the internal IP in DNS is suboptimal. Having multiple public IP addresses on the VPS should solve that problem.

Alternatively you can use routing policies, that match on protocol or port number and use different routing tables. The exact configuration of this depends on the OS on the client.

  • having trouble with routing policies, cannot get it working :/ acquiring another ip from my provider didn't occur to me but is the way I'll take. so thanks :) – graywolf Sep 17 '14 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.