Skip to contentSkip to conversation

IP TOS based routing

DISCUSSION Simone Leggio 5 participants 7 messages Mar 25, 2003 – Apr 1, 2003

lore
Share & tools
lore
#0 lore raw

Hi all,

I have to send prioritised traffic from host A to host B.

The priority 1 is identified by an IP TOS value of, say 46. The priority 2 is identified by an IP TOS value of, say 26.

In my network topology, there are two possible routes from host A to host B, one through host A's network interface eth0 and the other one through eth1.

I'd like to know whether it is possible, and if so how, with traffic control to set filters so that packets with TOS 46 are sent to host B via eth0 and packets with TOS 26 via eth1.

Note that the destination address for all the packets is the same, what I need is just to route through different interfaces to the same destination.

Thank you.

Simone.

#1 lore raw
Quoted 11 lines · Simone Leggio

Hi all,

I have to send prioritised traffic from host A to host B.

The priority 1 is identified by an IP TOS value of, say 46. The priority 2 is identified by an IP TOS value of, say 26.

In my network topology, there are two possible routes from host A to host B, one through host A's network interface eth0 and the other one through eth1.

Quoted 8 lines

I'd like to know whether it is possible, and if so how, with traffic control to set filters so that packets with TOS 46 are sent to host B via eth0 and packets with TOS 26 via eth1.

Note that the destination address for all the packets is the same, what I need is just to route through different interfaces to the same destination.

Hi Simone,

Try to use the mangle table to mark your packets which match a specific TOS, and then add a second routing table with the alternative default connection. That should work. You can find more info on:

http://linux-ip.net/html/adv-multi-internet.html
http://www.ssi.bg/~ja/nano.txt

/Kim

#2 lore raw
Quoted 9 lines · Kim Jensen
Quoted 3 lines · Simone Leggio

I'd like to know whether it is possible, and if so how, with traffic control to set filters so that packets with TOS 46 are sent to host B via eth0 and packets with TOS 26 via eth1.

Hi Simone,

Quoted 8 lines

Try to use the mangle table to mark your packets which match a specific TOS, and then add a second routing table with the alternative default connection. That should work. You can find more info on:

http://linux-ip.net/html/adv-multi-internet.html
http://www.ssi.bg/~ja/nano.txt

/Kim

Hi Kim,

thanks for the answer.
At the moment I have a test network where I send traffic from host A to host B generating it with a proper traffic generator (for example MGEN), which allows also to set the DS (or IP TOS) field. Does iptables understand the value set before with the traffic generator or I have to set the field with the mangle table?
What I was thinking to type to discriminate the output interface was:

iptables -A FORWARD -p tcp -m tos --tos TOS -o INTERFACE -j ACCEPT

With TOS equal to the value set by the traffic generator. Would it work?

Simone.

#3 lore raw

Hello,

I have a problem like this. Can somebody tell me how I can use 'ip route' to do DSCP field based routing. I now can only use the TOS fields, but I want to use the DS fields too.

How Come?

Regards Rinse
----- Original Message -----
From: "Simone Leggio" <[email protected]>
To: "Kim Jensen" <[email protected]>
Cc: <[email protected]>
Sent: Thursday, March 27, 2003 8:32 AM
Subject: Re: IP TOS based routing

Quoted 41 lines
Quoted 10 lines · Kim Jensen
Quoted 3 lines · Simone Leggio

I'd like to know whether it is possible, and if so how, with traffic control to set filters so that packets with TOS 46 are sent to host B via eth0 and packets with TOS 26 via eth1.

Hi Simone,

Try to use the mangle table to mark your packets which match a

specific TOS,

Quoted 1 line

and then add a second routing table with the alternative default

connection.

Quoted 6 lines

That should work. You can find more info on:

http://linux-ip.net/html/adv-multi-internet.html
http://www.ssi.bg/~ja/nano.txt

/Kim

Hi Kim,

thanks for the answer.
At the moment I have a test network where I send traffic from host A to host B generating it with a proper traffic generator (for example MGEN), which allows also to set the DS (or IP TOS) field.
Does iptables understand the value set before with the traffic generator or I have to set the field with the mangle table?
What I was thinking to type to discriminate the output interface was:

iptables -A FORWARD -p tcp -m tos --tos TOS -o INTERFACE -j ACCEPT

With TOS equal to the value set by the traffic generator. Would it work?

Simone.

#4 lore raw
Quoted 9 lines · Rinse Kloek

Hello,

I have a problem like this. Can somebody tell me how I can use 'ip route' to do DSCP field based routing. I now can only use the TOS fields, but I want to use the DS fields too.

How Come?

Regards Rinse

The DS field is a TOS field "masked", so the use is pretty similar. Only, pay attention because the coding is slightly different. I suggest to take a look to Linux traffix control tool howto:

http://lartc.org/

It is very well specified how to play with differentiated services, and thus with the DS field. It is not stirctly related to routing, but it might give you an idea about the coding. With regard to routing, I'm working on it too, so unfortunely I cannot help you so much.

Simone.

#5 lore raw
In reply to Simone Leggio
Quoted 11 lines · Simone Leggio

At the moment I have a test network where I send traffic from host A to host B generating it with a proper traffic generator (for example MGEN), which allows also to set the DS (or IP TOS) field.
Does iptables understand the value set before with the traffic generator or I have to set the field with the mangle table?
What I was thinking to type to discriminate the output interface was:

iptables -A FORWARD -p tcp -m tos --tos TOS -o INTERFACE -j ACCEPT

With TOS equal to the value set by the traffic generator. Would it work?

Hi Simone,

Ensure that you have one routing table for each interface, then use the command:

$ip rule add fwmark x table y

Then add a mangle entry in your prerouting table, which looks at the tos you wish to match:

$iptables -t mangle -A PREROUTING -p tcp -m tos --tos TOS -j MARK --set-mark x

That should hopefully do it. The script for copying your routing table is available in the link: http://linux-ip.net/html/adv-multi-internet.html.

hope this helps

/Kim

#6 lore raw
In reply to Kim Jensen
Quoted 8 lines · Kim Jensen
Quoted 7 lines · Simone Leggio

Hi all,

I have to send prioritised traffic from host A to host B.

The priority 1 is identified by an IP TOS value of, say 46. The priority 2 is identified by an IP TOS value of, say 26.

Quoted 7 lines
Quoted 7 lines

In my network topology, there are two possible routes from host A to host B, one through host A's network interface eth0 and the other one through eth1.

I'd like to know whether it is possible, and if so how, with traffic control to set filters so that packets with TOS 46 are sent to host B via eth0 and packets with TOS 26 via eth1.

ip route add default tos 0x46 dev eth0
ip route add default tos 0x26 dev eth1

Assuming that your TOS values are in Hex. Note also that this will only work for local hop (direct connect) packets. In order to route the TOS then you use:

ip route add default tos 0x46 via 1.1.1.1 src 2.2.2.2

with appropriate IP addrs.

Quoted 6 lines
Quoted 4 lines

Note that the destination address for all the packets is the same, what I need is just to route through different interfaces to the same destination.

Hi Simone,

Quoted 10 lines

Try to use the mangle table to mark your packets which match a specific TOS, and then add a second routing table with the alternative default connection. That should work. You can find more info on:

http://linux-ip.net/html/adv-multi-internet.html
http://www.ssi.bg/~ja/nano.txt

/Kim

--------------------------------------------------
Matthew G. Marsh, President
Paktronix Systems LLC
1506 North 59th Street
Omaha NE 68104
Phone: (402) 553-2288
Email: [email protected]
WWW: http://www.paktronix.com
--------------------------------------------------