LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-23-2010, 10:20 PM   #1
netxus
LQ Newbie
 
Registered: Feb 2010
Posts: 1

Rep: Reputation: 0
iptables rules


Hi..
Anyone can help me..I have setup my linux fedora server and i want to restrict access to my server.Basically i control using iptables.I'm not sure how to write an iptables rules to control drop all connection to port 8080 and allow only certain ip can access the instance on port 8080 example ip=10.254.14.16,192.168.1.10.

Thank in advance ya
 
Old 02-23-2010, 11:02 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Something like
Code:
iptables -I INPUT -s 192.168.1.10 -p tcp --dport 8080 -j ACCEPT
iptables -I INPUT -s 10.254.14.16 -p tcp --dport 8080 -j ACCEPT
iptables -I INPUT -p tcp --dport 8080 -j DROP
Untested !
 
1 members found this post helpful.
Old 02-24-2010, 03:30 AM   #3
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by chrism01 View Post
Something like
Code:
iptables -I INPUT -s 192.168.1.10 -p tcp --dport 8080 -j ACCEPT
iptables -I INPUT -s 10.254.14.16 -p tcp --dport 8080 -j ACCEPT
iptables -I INPUT -p tcp --dport 8080 -j DROP
Untested !
You've got the order of your rules inverted. Since you're inserting instead of appending, that last command would create the first rule in the chain, thereby sending all port 8080/TCP packets to DROP. Basically, you should instead have something like:
Code:
iptables -I INPUT -p tcp --dport 8080 -j DROP
iptables -I INPUT -s 192.168.1.10 -p tcp --dport 8080 -j ACCEPT
iptables -I INPUT -s 10.254.14.16 -p tcp --dport 8080 -j ACCEPT
Quote:
Originally Posted by netxus View Post
Hi..
Anyone can help me..I have setup my linux fedora server and i want to restrict access to my server.Basically i control using iptables.I'm not sure how to write an iptables rules to control drop all connection to port 8080 and allow only certain ip can access the instance on port 8080 example ip=10.254.14.16,192.168.1.10.
Are you sure you only want to filter port 8080/TCP?

That's what the rules above do, but it's a better idea to filter everything (IMO, at least).

Last edited by win32sux; 02-24-2010 at 03:31 AM.
 
Old 02-24-2010, 06:30 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,358

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
That's why I said untested; didn't have time or a system to check it on. Was A ('append' in my head).

I agree a more general soln is better; that was just a hint.
 
  


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
iptables 1.27a still loading rules after installing iptables 1.3.0 yawe_frek Linux - Software 1 06-07-2007 09:50 PM
Help with iptables rules rejeep Linux - Security 3 04-04-2007 05:15 AM
where are my new iptables-rules? xpucto Fedora 4 03-21-2007 07:42 AM
IPTABLES - rules in /etc/sysconfig/iptables The_JinJ Linux - Newbie 6 11-20-2004 01:40 AM
iptables rules Fatz Linux - Security 1 08-05-2004 06:04 AM

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

All times are GMT -5. The time now is 01:49 PM.

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