setting DiffServ in network packets under Linux???

Kevin D. Clark kevin_d_clark-Wuw85uim5zDR7s880joybQ at public.gmane.org
Tue Jan 12 13:58:48 EST 2010


Bill Bogstad writes:

> On Wed, Jan 6, 2010 at 4:36 PM, Bill Bogstad  wrote:
> > Does anybody have any idea if there is a programmatic way to set the
> > DiffServ (Differentiated Services Code Point (DSCP)) field on IP
> > packets generated by programs running under Linux?
> 
> Never mind.   It appears that you can use setsockopt() with IPPROTO_IP
> and IP_TOS options to do this.
> At least that's what the documentation seems to say.

At a previous company, I experimented around with doing this via
setsockopt(...IP_TOS...) and via iptables.  Either way works.

Eventually, I determined (for myself) that doing this via iptables was
better (for my situation) because setsockopt(...IP_TOS...) requires
root privileges, and I wanted to minimize the number of places in
which my server had to run as root.

(in fact, soon after the time that I added this iptables stuff to our
product I also I added code to my server that disallowed it from
being run as root, unless the
"--i-want-to-run-this-server-incorrectly-as-root" flag was set...I
recommend this pattern...)

Regards,

--kevin
-- 
alumni.unh.edu!kdc                God, I loved that Pontiac.
http://kdc-blog.blogspot.com/         -- Tom Waits

GnuPG: D87F DAD6 0291 289C EB1E 781C 9BF8 A7D8 B280 F24E 





More information about the Discuss mailing list