Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

My Linux machine has two network ports with two IP addresses. I want to use one port for my VPN and accounting, and the other port for other usages. How can I tell Linux not to allow any requests from port 2 for Apache, MySQL, mailserver, ssh, etc. so it will use the VPN port, and likewise not allow port 1 to handle VPN traffic but allow everything else?

share|improve this question

migrated from stackoverflow.com Dec 8 '11 at 16:01

This question came from our site for professional and enthusiast programmers.

2 Answers 2

The ip(8) command can configure your interfaces and routing tables to do exactly as you desire. The Linux Advanced Routing And Traffic Control guide has the best description of how to use the ip(8) tool that I've yet found.

You need to make sure your routing tables know which interface is to be used for which IP ranges. Once you've defined that, typing it in is nearly a mechanical translation.

share|improve this answer

use a firewall (iptables for example), and configure your firewall to drop any vpn packet on the first interface.

don't forget to configure the route on your vpn software so that it uses the second interface. (the firewall will block the packets but will not tell the vpn software to retry on the other interface).

share|improve this answer
    
I'm not familiar with networking issues! can you give some examples?! –  sinoohe Dec 8 '11 at 9:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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