LinuxQuestions.org
Review your favorite Linux distribution.
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-01-2004, 10:20 AM   #1
gr00ve
Member
 
Registered: Jan 2004
Location: varies
Distribution: Blag, Slackware
Posts: 36

Rep: Reputation: 15
understanding iptables


hello all,

spent some time now trying to figure out iptables reading numerous posts & yet still i am not 100% clear. below are my ideas & questions if u could have a look through on those TXS !

iptables consists of 3 main chains
INPUT incoming packet
(source is the originators ip & destination is my nic's ip)
OUTPUT outgoing packet
(source is my nic's ip & destination some other host ip)
FORWARD routing
(source is my nic's ip & destination some other host ip)

(i don't want to think/consider mangle, conttrack & others, lets make it simple

rules are added to chains to accomodate the traffic
rules are in hierarchical order, so if i would be to do

iptables -I INPUT -p tcp ---source %ip where communication comes from% --destination %my nic's ip% --dport 1:64400 -j DROP
iptables -I INPUT -p tcp --source%ip where communication comes from% --destination %my nic's ip% --dport 80 -j ACCEPT
iptables -I OUTPUT -p tcp ---source %my nic's ip% --destination %some host% --dport 1:64400 -j DROP
iptables -I OUTPUT -p tcp --source%my nic's ip% --destination %some host% --dport 80 -j ACCEPT

now here as 1st step i block all traffic 1:64400, hence the request for incoming & outgoing packet for port 80 does not get anywhere, therefore I would need to do it in reverse, 1st rule that accepts the packet & lets it go somewhere & then block all <---- is this correct?
Also do I understand --source & --destination correctly on INPUT/OUTPUT example (--dport option in case of INPUT implies that this is my local port that will be open & in case of output it means that this will be the port open from some other remote host)?

now this is all fare & square when it comes to processs running on my own local box, hence input/output chains are used, however when say I ran some program that has some other user trying to connect to my box, I would also need FORWARD chain setup, so

IPTABLES -I FORWARD -p tcp --source anyhost ---destination %my nic's ip% --dport 80 -j ACCEPT

at this point comes the question, so the packet entered & successfully passed FORWARD chain, kewl, but where does it go after this? Is it going directly to the kernle or program that needs this connection? Or is it going to INPUT chain & then to kernel to process?
Is it possible to do routing (not to add NAT chain at all) for outgoing connection, so to use FORWARD to send the packet received on 1 box to another box, or FORWARD chain is only for directing traffic inside iptables itself?

Also not to mess around with restricting ports, I could have used IPTABLES -p DENY INCOMING, to set the policy to deny all untill condition of one of the filters was met?

hope this is not too boring questions here, any help would be appreciated

Last edited by gr00ve; 11-01-2004 at 10:22 AM.
 
Old 11-01-2004, 12:47 PM   #2
Pcghost
Senior Member
 
Registered: Feb 2003
Location: The Arctic
Distribution: Fedora, Debian, OpenSuSE and Android
Posts: 1,820

Rep: Reputation: 46
Normally PREROUTING and POSTROUTING handle the "where does it go after this" question. If you have a PREROUTING rule sending all incoming port 80 requests to your web server on the LAN, and a FORWARD rule allowing the forwarding, you should be all set. I don't know if you can accomplish port forwarding without a PREROUTING rule, but I doubt it. I defer to more knowledgeable sources for the answer to that.
 
  


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
help me understanding iptables logs ddaas Linux - Security 1 02-23-2005 09:08 AM
A better understanding! nny0000 Slackware 1 04-14-2004 12:01 PM
Understanding iptables Buckyjunior Linux - Networking 3 03-07-2004 06:18 AM
Understanding X?? ++ bdp Linux - General 2 02-25-2004 05:47 PM
Understanding df -k itsjustme Linux - General 6 10-28-2003 12:08 PM

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

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