iptables dropping lots of packets

Hello friends i want to block the packets which has payload only ff in hex format but when i try to following command

iptables --append FORWARD -i p1p1 -p UDP   -d  --match string  --algo kmp --hex-string '|ff|'  -m length --length 10 -j DROP

Open in new window

it drops all packets which include ff like 1213121ff000000    

how should i let it drop exact payload match
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gerwin Jansen, EE MVETopic Advisor Commented:
You may want to specify the full string to match like:

--hex-string '|ff 00 00 00 00 00 00 00|'

(or some other place of your ff)
nociSoftware EngineerCommented:
You did request to drop all UDP packets that contain 'ff' somewhere in the payload.

you probably meant -hex-string '| ff ff ff ff ff ff ff ff ff ff |'   for 10times ff

which would match any packet containing at least 10 times ff...
but it would miss a packet of size 6 containing only 6 time ff.
You can also make other cases like: checking for packet with length X and X occurences...
(as these are exact match patterns, you need to specify whole paterns)
 --hex-string '| ff |' --length 1
 --hex-string '| ff  ff |' --length 2
 --hex-string '| ff  ff ff |' --length 3
 --hex-string '| ff ff ff ff |' --length 4
 --hex-string '| ff ff ff ff ff|' --length 5
 --hex-string '| ff ff ff ff ff ff|' --length 6
--hex-string '| ff ff ff ff ff ff ff |' --length 7
which becomes rather inefficient.
Also better to first check for length and then content if this exact matching is needed.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FireBallITAuthor Commented:
that is what i exactly looking for
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Security

From novice to tech pro — start learning today.