Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My VPN filters port 25 (to prevent spam) but my ISP doesn't. The VPN takes over all traffic and changes the default gateway? How can I bypass the VPN to send mail? I want all outgoing traffic except on port 25 to continue using the VPN.

My setup:

router 192.168.0.1 (this is the default gateway when VPN is not connected)
eth0 192.168.0.185
tun0 10.8.0.202

I tried to use iptables to do something with --dport 25 but I don't really know my way around the firewall.

I am using Ubuntu 12.10.

Another thing is that 192.168.0.185 runs several servers (web, mail, ssh, ...). The 192.168.0.1 router forwards requests on those ports (80, 443, ...) to 192.168.0.185. To stop the VPN from interfering with this, I run:

ip rule add from 192.168.0.185 table 10
ip route add default via 192.168.0.1 table 10

All of my servers started working except mail (because of the same issue with port 25?) so I changed postfix to run on 2525 (and had the router forward port 25 there) and that got it working.

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.8.0.201      128.0.0.0       UG    0      0        0 tun0
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth0
10.8.0.1        10.8.0.201      255.255.255.255 UGH   0      0        0 tun0
10.8.0.201      0.0.0.0         255.255.255.255 UH    0      0        0 tun0
46.21.99.21     192.168.0.1     255.255.255.255 UGH   0      0        0 eth0
128.0.0.0       10.8.0.201      128.0.0.0       UG    0      0        0 tun0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U     1      0        0 eth0
share|improve this question

closed as not a real question by Falcon Momot, Ward, growse, gWaldo, Dave M May 24 '13 at 15:48

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Does your VPN really block outbound port 25 or simply ask that you relay all mail through their mail servers instead (like many home ISPs do)? Big difference. –  TheCleaner May 24 '13 at 18:03
add comment

1 Answer

Two possibilities come to mind:

  1. Add a static route to your external mail server's IP address which is explicitly routed via the Ethernet interface instead of the default route.

  2. Send out your outgoing mail to the external mail server on the submission port (587).

The best answer, though, is to run the mail server on a different (virtual) machine than the VPN, so that you can route its traffic appropriately. Routes can only be specified by IP address/network, not by port number.

share|improve this answer
    
1. I don't know how to do that. The mail server is 192.168.0.185, the machine connected to the VPN itself. 2. The question is about how postfix itself can deliver messages. For example, if I send an e-mail to someone@xyz.com, it's going to try to talk to xyz.com on port 25. –  Jason May 24 '13 at 17:41
    
Hm, you should fix that first. –  Michael Hampton May 24 '13 at 17:42
add comment

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