Hi,

I wanted to give a final result for my question.

I have dropped the idea of using iptables with the -m string match and I 
implemented it directly with tc in u32:

Am 08.04.2014 um 08:28 schrieb Christian Rößner <[email protected]>:

> Good morning,
> 
>>>> Another approach may be to look at the packets themselves. I've no idea if 
>>>> RTP packets have useful "headers" in them, but VoIP packets are likely to 
>>>> share certain characteristics in terms of size and frequency. So if you 
>>>> see a constant stream of regular size packets *both ways* between two 
>>>> specific IPs then there is a good chance that they are an RTP stream, and 
>>>> if they are small enough then they are likely to be voice.
>>> 
>>> I was thinking about the same idea. Maybe using -m string , if there is 
>>> useable content inside the packages.
> 
> I read through RCFs 1889 1890 3550 3551
> RTP and RTP profiles

filter parent 1: protocol ip pref 4 u32
filter parent 1: protocol ip pref 4 u32 fh 801: ht divisor 1
filter parent 1: protocol ip pref 4 u32 fh 801::800 order 2048 key ht 801 bkt 0 
flowid 1:11  (rule hit 121102 success 1)
  match 00110000/00ff0000 at 8 (success 110703 )
  match 80000000/c07f0000 at 28 (success 1 )
filter parent 1: protocol ip pref 4 u32 fh 801::801 order 2049 key ht 801 bkt 0 
flowid 1:11  (rule hit 121101 success 1)
  match 00110000/00ff0000 at 8 (success 110702 )
  match 80040000/c07f0000 at 28 (success 1 )
filter parent 1: protocol ip pref 4 u32 fh 801::802 order 2050 key ht 801 bkt 0 
flowid 1:11  (rule hit 121100 success 109925)
  match 00110000/00ff0000 at 8 (success 110701 )
  match 80080000/c07f0000 at 28 (success 109925 )
filter parent 1: protocol ip pref 4 u32 fh 801::803 order 2051 key ht 801 bkt 0 
flowid 1:11  (rule hit 11175 success 0)
  match 00110000/00ff0000 at 8 (success 776 )
  match 80090000/c07f0000 at 28 (success 0 )
filter parent 1: protocol ip pref 4 u32 fh 801::804 order 2052 key ht 801 bkt 0 
flowid 1:11  (rule hit 11175 success 0)
  match 00110000/00ff0000 at 8 (success 776 )
  match 800f0000/c07f0000 at 28 (success 0 )
filter parent 1: protocol ip pref 4 u32 fh 801::805 order 2053 key ht 801 bkt 0 
flowid 1:11  (rule hit 11175 success 0)
  match 00110000/00ff0000 at 8 (success 776 )
  match 80120000/c07f0000 at 28 (success 0 )

These rules match about 99,99% of all RTP traffic audio for VoIP telephony. At 
least for our SIP providers.

I put the following into /etc/shorewall/started:

-----------------------------------------------------------------------------
TC=/sbin/tc
DEV_BND=bond1.108
DEV_IFB=ifb0

echo -n "Adding filters to bond1.108, ifb0..."
# match protocol UDP
# match RTPv2, PT (PayloadType)
for codec in 00 04 08 09 0F 12; do
        ${TC} filter add dev ${DEV_BND} protocol ip parent 1:0 pref 4 u32 \
                match ip protocol 0x11 0xFF \
                match u16 0x80${codec} 0xC07F at 28 \
                flowid 1:110
        ${TC} filter add dev ${DEV_IFB} protocol ip parent 2:0 pref 4 u32 \
                match ip protocol 0x11 0xFF \
                match u16 0x80${codec} 0xC07F at 28 \
                flowid 2:110
done
-----------------------------------------------------------------------------

00,04,08 are all the codecs that you will find in the RTP specs. Also on 
wikipedia. The mask ensures that the first two bits for byte one match RTP 
version 2 and the 7F mask matches the 7 bit mask for the RTP PT field. This 
match can also handle conference calls, sequence numbers and markers. So I 
really like the u32 version :) What I tried was using nexthdr+8, but for some 
reason it did not match, so I decided to directly count from the beginning of 
an IP packet. Maybe someone knows the reason and might like to help me, but at 
least I have a final working solution.

A little wishlist feature for shorewall :) More u32 support in tcfilters and 
tcrules :) That would be awesome

Thanks

-Christian Rößner

--
[*] sys4 AG

http://sys4.de, +49 (89) 30 90 46 64
Franziskanerstraße 15, 81669 München

Sitz der Gesellschaft: München, Amtsgericht München: HRB 199263
Vorstand: Patrick Ben Koetter, Marc Schiffbauer
Aufsichtsratsvorsitzender: Florian Kirstein

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Shorewall-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/shorewall-users

Reply via email to