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


Closed Thread
  Search this Thread
Old 11-12-2005, 03:15 AM   #1
Jeewhizz
LQ Newbie
 
Registered: Apr 2002
Location: London, England
Distribution: Mandrake 8
Posts: 4

Rep: Reputation: 0
IP Tables


Hi there,

What's the correct IP Tables rule to open all ports to and from one ip?

I.e., I want to open all ports to and from 192.168.1.100

Thanks for your help,

Jee
 
Old 11-12-2005, 04:34 AM   #2
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
It depends a bit on your firewall layout. One simple - and, I believe, common - general set of rules is

(1) INPUT chain: allow ESTABLISHED and RELATED packets
(2) OUTPUT chain: allow NEW, ESTABLISHED and RELATED packets

If this is what you use, then all you have to do is open for NEW incoming packets (assuming your network interface is eth0):

iptables -I INPUT -i eth0 -p tcp --syn -m state --state NEW --source 192.168.1.100 -j ACCEPT

This is only for TCP traffic as you can see by the "-p tcp" part. This rule accepts incoming connections from 192.168.1.100, i.e. you can use ssh to login from 192.168.1.100, or access your web server or whatever.

To further also allow incoming NEW udp and icmp ("ping") packets, then add two more lines:

iptables -I INPUT -i eth0 -p udp -m state --state NEW --source 192.168.1.100 -j ACCEPT
iptables -I INPUT -i eth0 -p icmp -m state --state NEW --source 192.168.1.100 -j ACCEPT

The NEW state basically consists of "requests", which means that if you don't have any servers running on the box, then you don't need to accept anything NEW in the INPUT chain. Except for icmp stuff perhaps, if you want to be able to ping your box.

If you do NOT have your firewall set up according to (1) and (2) above, then add these lines (which are specifically written for 192.168.1.100):

iptables -I INPUT -i eth0 -m state --state ESTABLISHED,RELATED --source 192.168.1.100 -j ACCEPT
iptables -I OUTPUT -o eth0 -m state --state NEW,ESTABLISHED,RELATED --destination 192.168.1.100 -j ACCEPT

The first line here takes care of (1), and the second (2) - but only for 192.168.1.100. Especially the OUTPUT chain rule that accepts NEW, ESTABLISHED and RELATED packets outbound for 192.168.1.100 is rather silly. I think it's quite common to use variants of the above two rules that takes care of packets to and from all hosts:

iptables -I INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I OUTPUT -o eth0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

Cheers
 
Old 02-26-2009, 01:24 PM   #3
fahadaziz
LQ Newbie
 
Registered: Aug 2008
Posts: 27

Rep: Reputation: 15
Smile iptables rules

my opinion is in the form of the following rules may be i could be wrong if i do so please guide me as well because i am also learning iptables right now...

rule 1 for input:

iptables -A input -p tcp --sport 1:1023 -i eth0 -d 192.168.1.100 -j accept

rule 2 for output:

iptables -A output -p tcp --sport 1024:65535 -i eth0 -d 192.168.1.100 -j accept


may be this could be the answer of the aforementioned question.


Thanks and Regards,

Faddi
 
Old 02-26-2009, 01:27 PM   #4
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
fahadaziz, if you have a question please start your own thread.

Don't resurrect dead threads (this one has been dead for over three years).

Last edited by win32sux; 02-26-2009 at 01:30 PM.
 
  


Closed Thread



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
IP Tables help muru Linux - Security 3 09-27-2005 11:39 PM
what are ip tables? master Linux - Security 4 01-24-2005 07:59 PM
IP TABLES help chrisfirestar Linux - Networking 2 10-29-2003 12:24 PM
IP Tables - What are they? yorkshiresteve Linux - Security 3 07-08-2003 04:34 AM
Ip Tables Mag|c Linux - Security 3 06-26-2003 10:06 PM

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

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