LinuxQuestions.org
Visit Jeremy's Blog.
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 02-21-2009, 07:18 AM   #1
bobbera
Member
 
Registered: Jun 2007
Posts: 39

Rep: Reputation: 0
IPTABLES question : ftp access for some IPs only


Hi ,

I've been trying to configure iptables rules according to which ftp access will be granted only to the specific IPS list (10.63.3.244 and 10.63.3.250 for example ) , but not to a whole range of IPs like 192.168.1.0/24 .

When I grant ftp access to a the IPs with next rules

iptables -A INPUT -p tcp --dport 21 -s ! 10.53.3.244 -j REJECT
iptables -A INPUT -p tcp --dport 21 -s ! 10.33.3.250 -j REJECT

only first IP will have an ftp access and the second IP is being rejected due to the first rule worked already .

How I define iptables in this situation .
Do not want to use /etc/hosts.deny since ftp prompt will show up indicating ftp port opened .

Thanks .

Vlad .
 
Old 02-21-2009, 07:48 AM   #2
JulianTosh
Member
 
Registered: Sep 2007
Location: Las Vegas, NV
Distribution: Fedora / CentOS
Posts: 674
Blog Entries: 3

Rep: Reputation: 90
reverse your logic... set the default policy of the INPUT chain to DROP and ALLOW the hosts you want in.

google "basic iptables examples"

basically, you want a default policy of DROP for the input chain, allow established,related connections, then rules to allow the specific traffic you want.
 
Old 02-21-2009, 08:41 AM   #3
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Practically speaking, change this:
Code:
iptables -A INPUT -p tcp --dport 21 -s ! 10.53.3.244 -j REJECT
iptables -A INPUT -p tcp --dport 21 -s ! 10.33.3.250 -j REJECT
To this:
Code:
iptables -A INPUT -p tcp --dport 21 -s 10.53.3.244 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -s 10.33.3.250 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j DROP
 
Old 02-22-2009, 02:58 AM   #4
bobbera
Member
 
Registered: Jun 2007
Posts: 39

Original Poster
Rep: Reputation: 0
Thanks to win32sux , his solution worked perfect .

I wouldn't go to the switching default policy to DROP since then I have to deal with other protocols as well .

Thanks to all .
 
  


Reply

Tags
iptables



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 can I Access remote FTP servers on Private IPs dablew Linux - Networking 3 12-03-2007 01:14 AM
iptables question re FTP access rjeeves33 Linux - Networking 3 12-12-2005 06:55 PM
Question about iptables and multiple external IPs tvynr Linux - Networking 2 10-12-2005 07:48 PM
how to define a specific range of IPs and/or multiple IPs in an iptables rule?... TheHellsMaster Linux - Security 9 09-20-2004 10:06 AM
can you restrict ftp USER access to certain ips? linuxboy69 Linux - Software 2 02-26-2004 04:05 PM

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

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