LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-14-2006, 01:39 AM   #1
khairil
LQ Newbie
 
Registered: May 2005
Distribution: gentoo
Posts: 23

Rep: Reputation: 15
Outgoing ftp connection black/white list.


hello,

How do I create IP rules for outgoing ftp connection on my linux which was SuSe 8.2.

I have a list of 100+ host/ftp server where this linux box is allowed to ftp to and I want to block other ftp server so that my linux cannot connect to any other ftp server which is not in the allowed host. Is it possible to do that?

i have a friend told me that you can do that using 'iptables' but i'm not sure how to do it.
any help highly appreciated.

i already tried searching on this forum for this topic before but cannot find it. i'm sorry if i create duplicate post about this topic. please give me the link of the similar post and delete this post if that so.

thx!
 
Old 11-14-2006, 03:03 AM   #2
imagineers7
Member
 
Registered: Mar 2006
Distribution: BackTrack, RHEL, FC, CentOS, IPCop, Ubuntu, 64Studio, Elive, Dream Linux, Trix Box
Posts: 310

Rep: Reputation: 30
Hi Khairil,

Welcome to Linux Questions.org.

You may have a look at following links to do that.

http://iptables-tutorial.frozentux.n...-tutorial.html

&

http://easyfwgen.morizot.net/gen/



Aniruddha
 
Old 11-14-2006, 03:33 AM   #3
imagineers7
Member
 
Registered: Mar 2006
Distribution: BackTrack, RHEL, FC, CentOS, IPCop, Ubuntu, 64Studio, Elive, Dream Linux, Trix Box
Posts: 310

Rep: Reputation: 30
Hi again,


This would be the last rule in your ftp chain:-


iptables -I OUTPUT -p tcp --destination-port 21 -j DROP


And this rule should be applied for all hosts you want to allow:-


iptables -I OUTPUT -p tcp -d allowed-host.com --destination-port 21 -j ACCEPT





To dynamically enter it, Create a root readable list containing those hostnames and add following in your iptables script:-

Quote:
for ALLOWEDFTP in `cat filename-of-list`
do
iptables -I OUTPUT -p tcp -d $ALLOWEDFTP --destination-port 21 -j ACCEPT
done
iptables -I OUTPUT -p tcp --destination-port 21 -j DROP
Hope, This helps you out,


Aniruddha
 
Old 11-14-2006, 08:16 AM   #4
khairil
LQ Newbie
 
Registered: May 2005
Distribution: gentoo
Posts: 23

Original Poster
Rep: Reputation: 15
thx a lot imagenners7! that should give me some basic idea what iptables is all about.

but what if the remote ftp server uses a non standard port like 2121 or 22? is there any other way iptables can tell the outgoing connection is FTP connection beside by looking at port number?

thank a lot!
 
Old 11-15-2006, 02:05 AM   #5
imagineers7
Member
 
Registered: Mar 2006
Distribution: BackTrack, RHEL, FC, CentOS, IPCop, Ubuntu, 64Studio, Elive, Dream Linux, Trix Box
Posts: 310

Rep: Reputation: 30
Hi Khairil,


Yes, there is such module which does just that and it is contrack - ftp.

Please, go through the links that I provided above to know more,


Quote:
Linux has steep learning curve, and the most customizable os too!


Aniruddha
 
Old 11-16-2006, 10:29 PM   #6
khairil
LQ Newbie
 
Registered: May 2005
Distribution: gentoo
Posts: 23

Original Poster
Rep: Reputation: 15
conntrack ftp? that wud be very interesting.. thx
 
  


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
Perl Net::FTP - LIST Causes Connection Hang taylor_venable Programming 0 01-05-2006 03:59 PM
M10 TV-Out Black/White Bill Cosby Linux - Software 1 07-31-2005 07:05 PM
black and white video tgkspike Linux - Software 1 05-14-2004 03:12 PM
laser printer Black/white eis Linux - Hardware 3 05-06-2004 07:17 PM
Picture from TV-out is black and white vasudevadas Linux - Hardware 4 11-19-2003 01:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:46 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