FORWARD rules
Hi,
I had kept the default policy of FORWARD as drop.
Now, I wanted to see an internal machine from internet. So, I used DNAT as,
iptables -A PREROUTING -t nat -d <ext ip> -j DNAT --to <int ip> It didn't work. When I set the default FORWARD policy to ACCEPT it worked.
What is a better approach? I want to have a default DROP in FORWARD chain. My FORWARD chain looked like this,
$IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p udp -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 80 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 110 -j ACCEPT $IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
What more do I add to allow natting as well as a secure FORWARD policy? Is the position of ESTABLISHED rule ok?
Thanks a lot for the help in advance and waiting eagerly for the mails. With warm regards,
-Payal
Signature · 3 lines
"Visit GNU/Linux Success Stories" http://payal.staticky.com Guest-Book Section Updated.
Quoted 11 lines · Payal Rathod
Hi,
I had kept the default policy of FORWARD as drop.
Now, I wanted to see an internal machine from internet. So, I used DNAT as,iptables -A PREROUTING -t nat -d <ext ip> -j DNAT --to <int ip> It didn't work. When I set the default FORWARD policy to ACCEPT it worked.
What is a better approach? I want to have a default DROP in FORWARD chain. My FORWARD chain looked like this,
Keep the default "DROP" policy and just open whatever is needed including the DNAT'ed packets coming in.
The place of the ESTABLISHED,RELATED rule should be at the top of your rule set.
Ramin
Quoted 4 lines · Ramin Dousti
On Wed, Sep 10, 2003 at 11:22:53PM +0530, Payal Rathod wrote:
Keep the default "DROP" policy and just open whatever is needed including the DNAT'ed packets coming in.
Please explain in a bit more detail relating to my data. Will keeping the ESTABLISHED,RELATED rule at top and putting default DROP policy set it right?
Thanks a lot and waiting for the reply.
With warm regards,
-Payal
Quoted 5 lines
The place of the ESTABLISHED,RELATED rule should be at the top of your rule set.
Ramin
Signature · 3 lines
"Visit GNU/Linux Success Stories" http://payal.staticky.com Guest-Book Section Updated.
$IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p udp -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 80 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 110 -j ACCEPT $IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
What more do I add to allow natting as well as a secure FORWARD policy? Is the position of ESTABLISHED rule ok?
You need to add a chains for NEW packets with tcp-flags syn.You need replace from console :
$IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p udp -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 80 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 110 -j ACCEPT
to
-A FORWARD -d 125.125.125.0/32 -m state --state NEW -p tcp -m tcp --dport 53 --syn -j ACCEPT
-A FORWARD -d 125.125.125.0/32 -m state --state NEW -p udp -m udp --dport 53 -j ACCEPT
-A FORWARD -d 125.125.125.0/32 -m state --state NEW -p tcp -m tcp --dport 80 --syn -j ACCEPT
-A FORWARD -d 125.125.125.0/32 -m state --state NEW -p tcp -m tcp --dport 110 --syn -j ACCEPT
--
"Visit GNU/Linux Success Stories"
http://payal.staticky.com
Guest-Book Section Updated.
Quoted 13 lines · Payal Rathod
Hi,
I had kept the default policy of FORWARD as drop.
Now, I wanted to see an internal machine from internet. So, I used DNAT as,iptables -A PREROUTING -t nat -d <ext ip> -j DNAT --to <int ip> It didn't work. When I set the default FORWARD policy to ACCEPT it worked.
What is a better approach? I want to have a default DROP in FORWARD chain. My FORWARD chain looked like this,
Quoted 9 lines
$IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p udp -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 80 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 110 -j ACCEPT $IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
What more do I add to allow natting as well as a secure FORWARD policy? Is the position of ESTABLISHED rule ok?
You need to add NEW state in the above FORWARD rule for this to work.
$IPTABLES -A FORWARD -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
Quoted 3 lines
Thanks a lot for the help in advance and waiting eagerly for the mails. With warm regards,
-Payal
Vishwanath
Quoted 10 lines · Vishwanatn T. K.
Quoted 6 lines
$IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 110 -j ACCEPT $IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
What more do I add to allow natting as well as a secure FORWARD policy? Is the position of ESTABLISHED rule ok?
You need to add NEW state in the above FORWARD rule for this to work.
$IPTABLES -A FORWARD -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
Just confirming this from all. Please check whether this is ok.
$IPTABLES -I PREROUTING -t nat -p tcp -d 202.x.x.x -j DNAT --to 125.125.125.2
$IPTABLES -A INPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p udp -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 80 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 110 -j ACCEPT
echo "1" > /proc/sys/net/ipv4/ip_forward
$IPTABLES -P FORWARD ACCEPT
^^^^^^
$IPTABLES -A INPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
Can I now change the ACCEPT statement to DROP without any fear? Thanks a lot in advance and bye.
With warm regards,
-Payal
Signature · 3 lines
"Visit GNU/Linux Success Stories" http://payal.staticky.com Guest-Book Section Updated.
Quoted 1 line · Payal Rathod
Just confirming this from all. Please check whether this is ok.
[...]
Quoted 1 line
$IPTABLES -A INPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
With this rule, you will just accept anything, except INVALID packets that are quite uncommon (very most of them are ICMP).
Quoted 4 lines
$IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p udp -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 80 -j ACCEPT $IPTABLES -A FORWARD -s 125.125.125.0/32 -p tcp -m tcp --dport 110 -j ACCEPT
Thoses rules won't get reached, as first one accept all packets. You should consider this instead :
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -m state --state NEW -s 125.125.125.0/32 -p tcp \ -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -m state --state NEW -s 125.125.125.0/32 -p udp \ -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -m state --state NEW -s 125.125.125.0/32 -p tcp \ -m tcp --dport 80 -j ACCEPT $IPTABLES -A FORWARD -m state --state NEW -s 125.125.125.0/32 -p tcp \ -m tcp --dport 110 -j ACCEPT
Keeping ESTABLISHED,RELATED rule at top of ruleset is an optimization, as most packet you will receive will have ESTABLISHED state. It's better to treat them early so they don't go through the whole chain.
Quoted 5 lines
echo "1" >
/proc/sys/net/ipv4/ip_forward$IPTABLES -P FORWARD ACCEPT
^^^^^^$IPTABLES -A INPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
Same than below. It's about the same than an policy set to ACCEPT...
Quoted 1 line
Can I now change the ACCEPT statement to DROP without any fear?
Sure.
Signature · 2 lines
http://www.netexit.com/~sid/ PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
On Fri, 12 Sep 2003 12:45:34 +0200,
Cedric Blancher <[email protected]> wrote in message <[email protected]>:
Quoted 1 line
Quoted 1 line
$IPTABLES -A INPUT -m state --state NEW,ESTABLISHED,RELATED \
..lose "NEW".
Quoted 8 lines
Quoted 1 line
-j ACCEPT
Same than below. It's about the same than an policy set to ACCEPT...
Quoted 1 line
Can I now change the ACCEPT statement to DROP without any fear?
Sure.
Signature · 4 lines
..med vennlig hilsen = with Kind Regards from Arnt... ;-) ...with a number of polar bear hunters in his ancestry... Scenarios always come in sets of three: best case, worst case, and just in case.
Quoted 4 lines · Arnt Karlsen
On Fri, 12 Sep 2003 12:45:34 +0200,
Cedric Blancher <[email protected]> wrote in messageQuoted 1 line
Quoted 1 line
$IPTABLES -A INPUT -m state --state NEW,ESTABLISHED,RELATED \
..lose "NEW".
Just what I said, wasn't it ?
Signature · 2 lines
http://www.netexit.com/~sid/ PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
On Fri, 12 Sep 2003 16:51:41 +0200,
Cedric Blancher <[email protected]> wrote in message <[email protected]>:
Quoted 7 lines · Arnt Karlsen
Quoted 4 lines
On Fri, 12 Sep 2003 12:45:34 +0200,
Cedric Blancher <[email protected]> wrote in messageQuoted 1 line
Quoted 1 line
$IPTABLES -A INPUT -m state --state NEW,ESTABLISHED,RELATED \
..lose "NEW".
Just what I said, wasn't it ?
..nah, but you probably _meant_ it. ;-)
Signature · 4 lines
..med vennlig hilsen = with Kind Regards from Arnt... ;-) ...with a number of polar bear hunters in his ancestry... Scenarios always come in sets of three: best case, worst case, and just in case.
Quoted 6 lines · Arnt Karlsen
On Fri, 12 Sep 2003 16:51:41 +0200,
Quoted 3 lines
Quoted 1 line
..lose "NEW".
Just what I said, wasn't it ?
..nah, but you probably _meant_ it. ;-)
I think he said it :). Look below.
| $IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | $IPTABLES -A FORWARD -m state --state NEW -s 125.125.125.0/32 -p tcp \ | -m tcp --dport 53 -j ACCEPT
-Payal
Signature · 3 lines
"Visit GNU/Linux Success Stories" http://payal.staticky.com Guest-Book Section Updated.
On Sat, 13 Sep 2003 07:56:58 +0530,
Payal Rathod <[email protected]> wrote in message <[email protected]>:
Quoted 8 lines · Arnt Karlsen
Quoted 6 lines
On Fri, 12 Sep 2003 16:51:41 +0200,
Quoted 3 lines
Quoted 1 line
..lose "NEW".
Just what I said, wasn't it ?
..nah, but you probably _meant_ it. ;-)
Quoted 8 lines
I think he said it :). Look below.
| $IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | $IPTABLES -A FORWARD -m state --state NEW -s 125.125.125.0/32 -p tcp | \ -m tcp --dport 53 -j ACCEPT-Payal
..wrong snippet. ;-) Reread the thread, and you'll see both I and Cedric weren't to clear on that we meant to say, we _implied_ things instead of actually _saying_ them, I snipped to hard and lost Cedric, and added to the confusion. I'm talking about the "NEW" under this bit:
" > $IPTABLES -P FORWARD ACCEPT
Quoted 1 line
^^^^^^ ".
Signature · 4 lines
..med vennlig hilsen = with Kind Regards from Arnt... ;-) ...with a number of polar bear hunters in his ancestry... Scenarios always come in sets of three: best case, worst case, and just in case.
Quoted 3 lines · Arnt Karlsen
..wrong snippet. ;-) Reread the thread, and you'll see both I and Cedric weren't to clear on that we meant to say, we _implied_ things instead of actually _saying_ them
So, for the things to get clear, the whole script should be[1] :
$IPTABLES -P FORWARD DROP
$IPTABLES -P INPUT DROP
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -m state --state NEW -s 125.125.125.0/32 -p tcp \
-m tcp --dport 53 -j ACCEPT
$IPTABLES -A FORWARD -m state --state NEW -s 125.125.125.0/32 -p udp \
-m tcp --dport 53 -j ACCEPT
$IPTABLES -A FORWARD -m state --state NEW -s 125.125.125.0/32 -p tcp \
-m tcp --dport 80 -j ACCEPT
$IPTABLES -A FORWARD -m state --state NEW -s 125.125.125.0/32 -p tcp \
-m tcp --dport 110 -j ACCEPT$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
echo "1" > /proc/sys/net/ipv4/ip_forward
A -m state --state NEW,ESTABLISHED,RELATED _should not_ be used, as it's an quasi-generic full match (i.e. nearly matches all packets).
[1] Note I did a typo in my <[email protected]> post, it's FORWARD, not INPUT...
Signature · 2 lines
http://www.netexit.com/~sid/ PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
On Mon, 15 Sep 2003 09:56:22 +0200,
Cedric Blancher <[email protected]> wrote in message <[email protected]>:
Quoted 26 lines · Arnt Karlsen
Quoted 3 lines
..wrong snippet. ;-) Reread the thread, and you'll see both I and Cedric weren't to clear on that we meant to say, we _implied_ things instead of actually _saying_ them
So, for the things to get clear, the whole script should be[1] :
$IPTABLES -P FORWARD DROP
$IPTABLES -P INPUT DROP$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -m state --state NEW -s 125.125.125.0/32 -p tcp \ -m tcp --dport 53 -j ACCEPT $IPTABLES -A FORWARD -m state --state NEW -s 125.125.125.0/32 -p udp \ -m tcp --dport 53 -j ACCEPT$IPTABLES -A FORWARD -m state --state NEW -s 125.125.125.0/32 -p tcp
\ -m tcp --dport 80 -j ACCEPT
$IPTABLES -A FORWARD -m state --state NEW -s 125.125.125.0/32 -p tcp
\ -m tcp --dport 110 -j ACCEPT$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
echo "1" >
/proc/sys/net/ipv4/ip_forward
Quoted 7 lines
A -m state --state NEW,ESTABLISHED,RELATED
_shouldnot_be used, as it's an quasi-generic full match (i.e. nearly matches all packets).[1] Note I did a typo in my <[email protected]> post, it's FORWARD, not INPUT...
..me too, ;-) I ofcourse meant we "weren't too clear on what we meant to say"... ;-)
Signature · 4 lines
..med vennlig hilsen = with Kind Regards from Arnt... ;-) ...with a number of polar bear hunters in his ancestry... Scenarios always come in sets of three: best case, worst case, and just in case.
Quoted 2 lines · Arnt Karlsen
..me too, ;-) I ofcourse meant we "weren't too clear on what we meant to say"... ;-)
We are now, that's the important point :)
Signature · 2 lines
http://www.netexit.com/~sid/ PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
Quoted 5 lines · Cedric Blancher
Quoted 2 lines · Arnt Karlsen
..me too, ;-) I ofcourse meant we "weren't too clear on what we meant to say"... ;-)
We are now, that's the important point :)
I am still confused. What you really meant and what you really said. Are you losing your brains or am I :)
-Payal
Quoted 4 lines
Signature · 2 lines
http://www.netexit.com/~sid/ PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE
Signature · 2 lines
For GNU/Linux Success Stories and Articles visit:
http://payal.staticky.comOn Tue, 16 Sep 2003 04:28:23 +0000,
Payal Rathod <[email protected]> wrote in message <[email protected]>:
Quoted 10 lines · Cedric Blancher
Quoted 5 lines · Arnt Karlsen
Quoted 2 lines
..me too, ;-) I ofcourse meant we "weren't too clear on what we meant to say"... ;-)
We are now, that's the important point :)
I am still confused. What you really meant and what you really said. Are you losing your brains or am I :)
-Payal
.. ;-) You wanna reread what Cedric wrote in his message
<[email protected]>.
Signature · 4 lines
..med vennlig hilsen = with Kind Regards from Arnt... ;-) ...with a number of polar bear hunters in his ancestry... Scenarios always come in sets of three: best case, worst case, and just in case.
Quoted 2 lines · Vishwanatn T. K.
You need to add NEW state in the above FORWARD rule for this to work. $IPTABLES -A FORWARD -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
It will let is firewall wide open.
Signature · 2 lines
http://www.netexit.com/~sid/ PGP KeyID: 157E98EE FingerPrint: FA62226DA9E72FA8AECAA240008B480E157E98EE