a late reply
:
Quote:
Originally posted by Soulful93
It seems like your appending quite a bit, from which I just read appends a rule to the bottom of the ruleset. Is there a need for a specific order that you have to enter your rules?
|
yeah, the "-A" adds the rule to the bottom of the chain... "-I" adds it to the top... the rules are read top to bottom, so it DEFINITELY matters what order they are in...
analogical example: you have your iptables script running smoothly, everything is working fine... then one day you need to block IP address 192.168.200.101 from reaching your server for whatever reason... it's an emergency, so you wanna do it quickly from the command line interface (without editing and/or re-running your script)...
you might be tempted to do a:
Code:
iptables -A INPUT -s 192.168.200.101 -j DROP
but as you can see, the "-A" will
append the command to the end of your INPUT chain... so packets coming from 192.168.200.101 will still get accepted by the rules above your new rule... the proper way to completely cut-off 192.168.200.101 would be:
Code:
iptables -I INPUT -s 192.168.200.101 -j DROP
now you now the rule will be
inserted at the top of the chain, so all packets will go through the rule... so now you are sure that any packets from 192.168.200.101 will be filtered (until you reboot, re-run your script, or flush the tables in some other way)...
Quote:
Also, I'm not understanding what your doing with the -J RETURN. What does RETURN do?
|
we use the RETURN target in our user chains... it's purpose is to send the packet back to the "parent" chain... basically, when you add the RETURN target to the end of a user chain, what you are saying is:
"okay, the packet didn't match any rules in this chain, so send it back and let it continue traversing the rules in the parent chain where it came from"...
AFAIK you can also use it as a target mid-chain itself with some specific matches, so as to return certain packets without having to traverse the entire chain...
(BTW i don't think it's technically called a "parent" chain but you get the idea...)