changing the ToS in IP Header

Kenjiro Cho kjc at csl.sony.co.jp
Mon May 26 20:13:41 PDT 2003


Ashish Kulkarni wrote:
> Is there any way in which I can manipulate the Type of Service (TOS) byte
> in the IPv4 header? I need to set the TOS bits on all outgoing packets from
> my box to the ISP to a particular pattern (0x02), as otherwise the ISP does
> not forward packets.

Tell your ISP not to use 0x02; it violates the standard.
You may modify the upper 6 bits for an arbitrary value, though.
The lower 2 bits of the (now deprecated) TOS field are officially
assigned to ECN (RFC3168).  0x02, ECT(0), is used to indicate that the
sender is ECN-capable.

> I have been able to do this in Linux using the
> iptables mangle table:
> 
> http://www.tldp.org/LDP/nag2/x-087-2-firewall.tos.manipulation.html
> 
> but am unable to find a similiar packet-mangling feature in the firewalls
> running on FreeBSD...there are rules for matching on TOS pattern, but not
> on TOS manipulation. Does anyone know of any tool which can do this?

ALTQ supports diffserv and is capable of rewriting the upper 6 bits of
the TOS field.
http://www.csl.sony.co.jp/~kjc/software.html

-Kenjiro


More information about the freebsd-hackers mailing list