LinuxQuestions.org
Help answer threads with 0 replies.
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 09-15-2010, 08:04 PM   #1
velvetpipes
LQ Newbie
 
Registered: Sep 2010
Posts: 2

Rep: Reputation: 0
noob question about IPtables


I'm a long time lurker here, but finally couldnt find an answer so had to sign up. :P


I'm helping a friend set up a server online and I'm learning as I go, but one thing has me sorta stumped.

I'm trying to restrict non local access to certain ports from certain IPs.
Example, I want to set up a whitelist so that only say 123.45.67.89 can connect to the server on port 21, and all other connections to port 21 are refused.
I've searched and found ways to whitelist a port to all IPs, and ways to whitelist all IPs to a port, but not how to whitelist a single IP - port combo.

Taken one step further, since he has a dynamic IP with his ISP, how can I whitelist a range of IPs to a single port. say 123.45.67.*

Any help would be greatly appreciated.

Last edited by velvetpipes; 09-16-2010 at 10:21 PM. Reason: spelling corrections
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 09-15-2010, 08:35 PM   #2
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
iptables -A INPUT -s 123.45.67.0/24 -p tcp --dport 21 -j ACCEPT
iptables -A INPUT -s 123.45.67.0/24 -m state ESTABLISHED,RELATED -j ACCEPT

second rule might be needed depending on how the rest of your firewall is configured since ftp opens extra ports
 
3 members found this post helpful.
Old 09-15-2010, 09:56 PM   #3
hermitcl
LQ Newbie
 
Registered: Feb 2008
Posts: 2

Rep: Reputation: 3
and then don't forget to either have DENY or DROP in your INPUT chain policy, or add the line

iptables -A INPUT -p tcp --dport 21 -j DROP

below the others.
 
2 members found this post helpful.
Old 09-16-2010, 01:23 AM   #4
ddaemonunics
Member
 
Registered: May 2008
Location: Romania
Distribution: Debian
Posts: 242

Rep: Reputation: 41
for one IP:
iptables -A INPUT -s !123.45.67.89 -p tcp --dport 21 -j DROP
with a default INPUT -P ACCEPT


with default INPUT -P DROP
iptables -A INPUT -s 123.45.67.89 -p tcp --dport 21 -j ACCEPT

Last edited by ddaemonunics; 09-16-2010 at 01:26 AM.
 
3 members found this post helpful.
Old 09-16-2010, 10:21 PM   #5
velvetpipes
LQ Newbie
 
Registered: Sep 2010
Posts: 2

Original Poster
Rep: Reputation: 0
sweet, thanks a ton guys!
Gotta love learning new stuff.
 
  


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
Noob question: Iptables maxsthecat Linux - Networking 1 08-13-2006 01:02 AM
Squid and IPTables - nooB looking for safety xprezons Linux - Security 2 08-08-2005 07:31 AM
noob with a noob question phoonerorlater Linux - Newbie 2 09-29-2004 03:43 PM
Complete noob question from a noob noob_hampster Linux - Software 2 09-04-2003 12:03 AM
IPtables Noob Help pls Phat420 Linux - Networking 6 03-11-2003 09:55 PM

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

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