LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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-14-2005, 12:47 PM   #1
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676
Blog Entries: 7

Rep: Reputation: 32
simple iptable question


Ive been studyin IPtables for a day or two I just have one question:

If I wana set up a firewall and SNAT (masquerading):

I enter all the firewall rules at first
After that I append the nating rules coz they must be at the end right ??

Now suppose I want to change my firewall rules ......I enter the new or changed rules and then what ???

Do I have to re-enter the natting info so that it is appended at the end...
or is it normall to re-enter firewall rules after the natting rules ( although that does not sound correct )
 
Old 11-15-2005, 06:55 PM   #2
SirGertrude
Member
 
Registered: May 2004
Location: Missouri
Distribution: Gentoo
Posts: 59

Rep: Reputation: 15
The only time you need to be concerned with the placement of rules is when you are dealing with rules in the same chain.

There are three tables in netfilter by default:

- Mangle
- NAT
- Filter

Any packet that arrives at your interface will always follow the above path from top to bottom.

Inside each table there are several default chains:

- Mangle
------- Prerouting (Add marks, TOS, etc before routing process occurs)
------- Output (Add marks, TOS, etc to packets originating locally)
- NAT
------- Prerouting (Affects packets before routing process)
------- Output (Affects packets originating locally)
------- Postrouting (Affects packets after routing process)
- Filter
------- Input (Affects packets coming in on an interface)
------- Output (Affects packets going out on an interface they were received on)
- Forward (Affects packets going in one interface and out another - between networks)


Rules in each chain should be placed in order of expected use. The reason for this is that once a packet matches a rule the action is preformed and the packet does consume anymore system resources. If you run a webserver you probably want the first rule in your input chain to be "iptables -A INPUT -p tcp --dport 80 -j ACCEPT".

You can view your rules and their positions using the command: "iptables -vnL --line-numbers". By default this shows the filter table. Use "-t" to show a different table. "iptables -vnL --line-numbers -t nat" will show all rules in the nat table including their position in their chains.

To answer your question... SNAT is preformed in the postrouting chain of the nat table, and since you will probably only have one rule for this you don't really need to worry about other changes effecting your SNAT rule. Just make sure that you are accepting traffic on the LAN interface (INPUT chain) and you employ a stateful firewall. There are always exceptions to this, but I don’t think you are creating anything phenomenal here.

Hope this helps.

Last edited by SirGertrude; 11-15-2005 at 06:56 PM.
 
Old 11-16-2005, 05:08 AM   #3
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
Thanks for the effort, I appreciate all the information you provided.
But I occasionally misinterpret information, so lets just make sure that I understood it right:

It does not matter in which order I enter the rules for seperate chains, so I might configure the NAT chain and after that the FILTER chain, aslong as I enter all commands correctly. The only thing that I have to worry about is that I enter the rules into each seperate chain correctly.

????
 
  


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
Ubuntu Fluxbox simple question, simple answer? generallimptoes Linux - Software 3 09-26-2005 02:03 PM
Iptable and ipchains question itebooks Linux - Software 9 04-07-2004 12:26 AM
Installing Programs - A simple question from my simple mind jmp875 Linux - Newbie 6 02-18-2004 09:03 PM
Really Simple Question israel Linux - Networking 1 06-23-2003 12:27 PM
simple question seeking simple answer enzo250gto Linux - Newbie 1 10-27-2001 04:08 AM

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

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