How to allow traffic just for specifed countries?


I need advice from a real linux-security guru. My server has been ddos-ed and whole network segment went down. Now i want to block all foreign traffic and allow just few countries.

How to setup this with iptables ( v1.4.10) ?

Also I got info from my datacenter, that such kind of ddos-attacks can't be solved and next time they will block all traffic to my server again... Is that true and won't iptables rules help here ?

Server log during the attack (29 port was used for pure-ftp):
Apr  9 22:14:49 cs kernel: TCP: Possible SYN flooding on port 29. Sending cookies.
Apr  9 22:14:54 cs kernel: last message repeated 8 times
Apr  9 22:14:54 cs kernel: net_ratelimit: 648 callbacks suppressed
Apr  9 22:14:54 cs kernel: TCP: Possible SYN flooding on port 29. Sending cookies.
Apr  9 22:14:59 cs kernel: last message repeated 9 times
Apr  9 22:14:59 cs kernel: net_ratelimit: 1662 callbacks suppressed
Apr  9 22:17:24 cs kernel: net_ratelimit: 13005 callbacks suppressed
Apr  9 22:17:24 cs kernel: TCP: Possible SYN flooding on port 29. Sending cookies.

Any other suggestions preventing ddos will be highly appreciated !
Who is Participating?
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.


You can not evade a DDoS attack by using a firewall alone. The server will still hang up if the firewall is busy blocking incoming connections.

Please refer the following link to get a better idea on this:

You could also make use of the DDoS evasion techniques like Cisco guard, that your data centre provides(in case of sudden/unexpected attacks).


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
tanelAuthor Commented:
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.