LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-25-2006, 11:29 AM   #1
Jeeves
LQ Newbie
 
Registered: Aug 2005
Location: Dortmund, Germany
Distribution: Gentoo, Mandrake, OpenBSD
Posts: 14

Rep: Reputation: 0
Add route based on port not ip?!


Hi,

I am sitting on a PC with 2 Interfaces. One is a ADSL connection with no quota and one a Link to the University's LAN/WAN and also access to the Uni's gateway.

Currently I am using the ADSL interface (ppp0) for my default route and the Uni interface (eth1) for my route to certain servers, like my mail and webservers for a nice, reliable and fast connection.

The routing table looks something like this:
Code:
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
213.191.89.28   *               255.255.255.255 UH    0      0        0 ppp0
10.4.0.0        *               255.255.0.0     U     0      0        0 eth1
129.0.0.0       10.4.11.1       255.0.0.0       UG    0      0        0 eth1
loopback        *               255.0.0.0       U     0      0        0 lo
default         213.191.89.28   0.0.0.0         UG    0      0        0 ppp0
My question is if there is any way to route packages going to *.*.*.*: port through the eth1 interface rather than the ppp0 interface?

My motivation is that I want to route packages going to ssh or ICQ servers through my Uni connection since it does not have the 24h disconnect unlike my ADSL interface.

I hope I have been specific enough.

Thanks in advance,

Jeeves
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 09-26-2006, 10:30 AM   #2
indeterminate
Member
 
Registered: Oct 2003
Location: Virginia, US
Distribution: Debian, Ubuntu, Knoppix.
Posts: 76

Rep: Reputation: 17
The Advanced Routing How-To describes pretty much exactly what you want to do:

http://www.tldp.org/HOWTO/Adv-Routin...netfilter.html

Basically, you edit your firewall rules to mark stuff from a specific port (ssh or icq, whatever) with a number. Then you configure iproute to send everything marked with that number out the correct interface.

It's a really good How-To.
 
2 members found this post helpful.
Old 12-01-2011, 10:40 PM   #3
ndarkduck
LQ Newbie
 
Registered: Nov 2008
Location: Mex,Mex
Distribution: Fedora || Red Hat Linux
Posts: 28

Rep: Reputation: 7
Quote:
Originally Posted by indeterminate View Post
The Advanced Routing How-To describes pretty much exactly what you want to do:

http://www.tldp.org/HOWTO/Adv-Routin...netfilter.html

Basically, you edit your firewall rules to mark stuff from a specific port (ssh or icq, whatever) with a number. Then you configure iproute to send everything marked with that number out the correct interface.

It's a really good How-To.
Is incredible how this post helped me today 2/Dec/2011. I'll like to summarise your link:
Code:
echo "1	UNIVERSITY" >> /etc/iproute2/rt_tables
ip route add default via 172.16.0.1 dev eth0 table UNIVERSITY
ip route show table UNIVERSITY
ip rule add from all fwmark 0x1 lookup UNIVERSITY
iptables -t mangle -I PREROUTING -p tcp --dport 22 -j MARK --set-mark 1
I'll like also to add the way to route certain outgoing reply traffic through a certain interface...
Code:
iptables -t mangle -I OUTPUT -p tcp --sport 22 -j MARK --set-mark 1
 
2 members found this post helpful.
Old 09-22-2013, 10:21 PM   #4
Oniric
LQ Newbie
 
Registered: Sep 2013
Posts: 1

Rep: Reputation: Disabled
Smile

Hello,

I'm just replying because this thread just made my day!
Thanks a lot for your answers, it's still useful even several years later !

I have a NAS connected to a VPN 24/7 on tun0 and all outgoing traffic si going through it. But to administrate it from outside i need to access it from another VPN through eth0.
I will work on that using your answers.
I will reply my founding later.

Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it not possible to route incomming port to another external port? ziggie216 Linux - Software 5 12-03-2005 06:16 PM
How do I add a route??? moonmoth Linux - Networking 3 09-04-2005 06:25 AM
I am not able to add a new route to my route table using route command prashanth s j Linux - Networking 2 09-03-2005 04:34 AM
route locally generated traffic to ip:port to localhost:port maenho Linux - Software 2 03-11-2005 04:08 AM
route add robf2301 Linux - Networking 6 03-11-2005 04:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration