LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 07-17-2009, 06:02 PM   #1
Silver565
Member
 
Registered: Jul 2007
Distribution: Ubuntu, Windows, Freenas
Posts: 96

Rep: Reputation: 15
Ubuntu and iptables?


Hi there

I have an ftp server (freenas) that i used to have up and running. However i have since shut it down because of an attack from korea(although they failed).

I wish to block all international traffic in some way... The only real solution i've come up with is iptables.(However any other easy solutions would be welcomed :-) )

(this article http://gofishingforum.net/software-a...rver-t606.html)

Is there an easy way to block all interntational traffic with iptables or some other way? as the only traffic i need coming in is from my own country (or even just my own city).

I have a spare computer that i can convert to ubuntu which can be located between the modem and the network

Cheers
 
Old 07-17-2009, 06:08 PM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by Silver565 View Post
Hi there

I have an ftp server (freenas) that i used to have up and running. However i have since shut it down because of an attack from korea(although they failed).

I wish to block all international traffic in some way... The only real solution i've come up with is iptables.(However any other easy solutions would be welcomed :-) )

(this article http://gofishingforum.net/software-a...rver-t606.html)

Is there an easy way to block all interntational traffic with iptables or some other way? as the only traffic i need coming in is from my own country (or even just my own city).

I have a spare computer that i can convert to ubuntu which can be located between the modem and the network

Cheers
Should be pretty easy to get an IP list such as this one and script your iptables commands off it. Just extract the IPs for your country and then send packets which don't match those IPs to DROP.
 
Old 07-17-2009, 06:37 PM   #3
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
For example, let's say you live in New Zealand. You could extract the IPs doing something like this:
Code:
zgrep "New Zealand" GeoIPCountryCSV.zip | awk -F"," {'print $1 $2'} | \
awk -F"\"" {'print $2 "-" $4'} > new_zealand_ips.txt
This gives you a text file with one IP range per line.

So to execute an iptables command for each range, you do something like this:
Code:
iptables -N CHECK_NEW_ZEALAND

for i in `cat /etc/new_zealand_ips.txt`; do
  iptables -A CHECK_NEW_ZEALAND -m iprange --src-range $i -j ACCEPT
done

iptables -A CHECK_NEW_ZEALAND -j DROP
This gives you a chain called CHECK_NEW_ZEALAND which will send to DROP any packet which doesn't match any of the ranges. You can send your packets into this chain from any other chain.

Last edited by win32sux; 07-17-2009 at 06:56 PM.
 
Old 07-17-2009, 11:09 PM   #4
Silver565
Member
 
Registered: Jul 2007
Distribution: Ubuntu, Windows, Freenas
Posts: 96

Original Poster
Rep: Reputation: 15
Ok thanks. I'm not familiar with those commands. But i'll have a look on the internet for iptables and how it works.
Thanks for the heads up
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to install iptables on ubuntu-8.0 and kernel-2.6.24 renuaseri Linux - Newbie 3 05-23-2011 11:08 PM
Some iptables rules are not working on Ubuntu 8.10 server PossumJerky Linux - Security 1 02-04-2009 07:47 AM
IPTables Help on Ubuntu 8.04 cedricd Linux - Server 1 11-10-2008 08:44 PM
iptables on Ubuntu 6.06 Server PetruM Linux - Security 3 07-18-2006 11:18 PM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 08:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 04:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration