Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using a linux box as a router:

The Box has 2 public ips and local ip, i'm using natting to allow local users to access the web.

When a local user access the web, source natting happens here, the packets going through the public interface are they checked through the OUTPUT chain or through the Forward chain ?

The same Question for the returned packets of the already established session are they check via the INPUT or forward chain ?

One last thing: Consider me as a local user the packets will go like this

PC ---> LinuxBox Local Interface ---> Linux Box Public interface ----> External world.

When the packets come back:

External Word ---->Public interface ----> Local interface ----->PC

If i want to apply a rule on the packet when they move from the local interface to the PC, should i use the FORWARD chain or the OUTPUT chain ?

What do you think ??

share|improve this question

2 Answers 2

Any packets going through the router is handled in the FORWARD chain. They will NEVER touch INPUT or OUTPUT.

Any packets that originate from the router itself will be handled by OUTPUT. Never FORWARD.

Any packets destined to an address that is assigned to one of the routers interfaces, will be handled by INPUT chain. Never FORWARD.

The only (kind-of) exception to the INPUT/OUTPUT never being handled by INPUT is if you apply any Destination NAT (as opposed to Source NAT) rules, in which case the destination of a packet originally destined for an address on one of the routers interfaces could be changed to something that is not, in which case it does go to FORWARD because the packet is no longer destined for an address on the local machine.

share|improve this answer

packets going from your land to the public network are handled in the forward chain. same thing for packets going the other way round. input are for packets for which final destination is the router itself (and are not batted), where ever they come from. and output is for packet originating from the router itself and going to the outside world (be it can or wan)

I don't understand your last question but keep in mind you can (and should) configure iptables to be stateful so you don't have to worry about packets from established session, only initial packet.

share|improve this answer
    
i have updated last question please check –  MohyedeenN Jan 8 at 7:32
    
This is a forwarded packet as well hence has to be treated in the forward chain. But as I told you iptables should be stateful so if you want to act on a packet that comes back from the wan make sure your rule comes before any "--state RELATED,ESTABLISHED -j ACCEPT" rule. Though I am not sure why you would need that. –  alxgomz Jan 8 at 8:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.