Statefull??
Quoted 34 lines · Wan Seman Bin Wan Ismail
Dear all,
I got a problem dealing with my current iptables rules
here is my iptables rules:-
$ipt -A FORWARD -i $EXT -o $DMZ -p tcp -m tcp -s 0/0 -d $WEB --dport 80
- -j LOG --log-level info --log-prefix "[IN WEB] :"
$ipt -A FORWARD -i $EXT -o $DMZ -p tcp -m tcp -s 0/0 -d $WEB --dport 80
- -j ACCEPT$ipt -A FORWARD -i ! $EXT -m state --state NEW -j ACCEPT $ipt -A FORWARD -i $EXT -m state --state ESTABLISHED,RELATED -j LOG
- --log-prefix "Established conn: "
$ipt -A FORWARD -i $EXT -m state --state ESTABLISHED,RELATED -j ACCEPT $ipt -A FORWARD -i $EXT -o $DMZ -p tcp -m tcp ! --tcp-flags SYN,RST,ACK SYN -m state --state NEW -j LOG --log-prefix "NEW NOT SYN: " $ipt -A FORWARD -i $EXT -o $DMZ -p tcp -m tcp ! --tcp-flags SYN,RST,ACK SYN -m state --state NEW -j DROP$ipt -A FORWARD -i $EXT -o $DMZ -p tcp -j LOG --log-level info
- --log-prefix " EXT-DMZ TCP DROP "
$ipt -A FORWARD -i $EXT -o $DMZ -p tcp -j REJECT $ipt -A FORWARD -i $DMZ -o $EXT -p tcp -j LOG --log-level info
- --log-prefix " DMZ-EXT TCP DROP "
$ipt -A FORWARD -i $DMZ -o $EXT -p tcp -j REJECT $ipt -A FORWARD -i $EXT -o $DMZ -p udp -j LOG --log-level info
- --log-prefix " EXT-DMZ UDP DROP "
$ipt -A FORWARD -i $EXT -o $DMZ -p udp -j REJECT $ipt -A FORWARD -i $DMZ -o $EXT -p udp -j LOG --log-level info
- --log-prefix " DMZ-EXT UDP DROP "
$ipt -A FORWARD -i $DMZ -o $EXT -p udp -j REJECT
Quoted 1 line
so my problem is why ppl outside can't browse my webpages?
Because you are REJECTing the reply packets from the server :)
Just take a look at the above rules, and think firstly about a SYN packet from the client (EXT) to the server (on the DMZ).
It will match the first and second rules, and therefore gets LOGged, and ACCEPTed.
Now think about the SYN ACK replly packet from the server (on the DMZ) to the client (EXT).
It will match the tenth and eleventh rules, and therefore gets LOGged and REJECTed.
Hope this explains the problem.
Regards,
Antony.
Signature · 7 lines
Behind the counter a boy with a shaven head stared vacantly into space,
a dozen spikes of microsoft protruding from the socket behind his ear.
- William Gibson, Neuromancer (1984)
Please reply to the list;
please don't CC me.Quoted 7 lines · Wan Seman Bin Wan Ismail
Antony Stone wrote:
| Because you are REJECTing the reply packets from the server :) |i still can't figure out, if i modified the rule then add this entry, ppl on my web (got shell access) can go anywhere.
Quoted 6 lines
$ipt -A SCAN -i $DMZ -o $EXT -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN
- -m state --state NEW -j REJECTThat's not what i want, what i need is my web server can serve ppl from outside but fw denied any new connections from the web server to outside.
I suggest you add a rule allowing ESTABLISHED,RELATED (but not NEW) packets
from the DMZ to EXT. That will allow replies but no new connections.
However, I also suggest you think very carefully about not allowing NEW connections from your web server to the outside world - specifically in relation to DNS - are you sure the web server itself never needs to do
external lookups (perhaps for visitor logs etc)? So long as this is true,
you'll be okay, but I think you should keep an eye on your netfilter log entries to see if the web server is trying to make some external connections which you actually decide you want to allow.
Regards,
Antony.
Signature · 5 lines
If you can't find an Open Source solution for it, then it isn't a real
problem.
Please reply to the list;
please don't CC me.Quoted 2 lines · Wan Seman Bin Wan Ismail
already did that and it's work.. thanks.. but somehow i would like to allow my web for updating security patches from xxxx server,
What TCP/UDP port/s does that require?
Quoted 17 lines
but the fw have rejected the req.
here is my rules:-
$ipt -A SCAN -i $EXT -o $DMZ -p tcp -m tcp -s 0/0 -d $WEB --dport 80 -j LOG --log-level info --log-prefix "[IN WEB] :"
$ipt -A SCAN -i $EXT -o $DMZ -p tcp -m tcp -s 0/0 -d $WEB --dport 80 -j ACCEPT$ipt -A SCAN -i $EXT -m state --state ESTABLISHED,RELATED -j LOG
- --log-prefix "Established conn: "
$ipt -A SCAN -i $EXT -m state --state ESTABLISHED,RELATED -j ACCEPT $ipt -A SCAN -i $EXT -o $DMZ -p tcp -m tcp ! --tcp-flags SYN,RST,ACK SYN -m state --state NEW -j LOG --log-prefix "NEW NOT SYN: " $ipt -A SCAN -i $EXT -o $DMZ -p tcp -m tcp ! --tcp-flags SYN,RST,ACK SYN -m state --state NEW -j DROP
Quoted 2 lines
$ipt -A FORWARD -i $DMZ -p tcp -m state --state NEW -s $WEB -d xxxx
- --dport 80 -j LOG --log-level info --log-prefix "OUT DNS :"
1. You appear to have a spare '-' in the above rule (also the one below)
2. DNS operates on TCP and UDP ports 53, not TCP port 80
Quoted 6 lines
$ipt -A FORWARD -i $DMZ -p tcp -m state --state NEW -s $WEB -d xxxx
- --dport 80 -j ACCEPT
$ipt -A FORWARD -i $DMZ -o $EXT -p tcp -m tcp -m state --state NEW -j LOG --log-level info --log-prefix "[Init DMZ] "
$ipt -A FORWARD -i $DMZ -o $EXT -p tcp -m tcp -m state --state NEW -j REJECT
By the way, you have some very good LOGging rules in this ruleset - make use
of them. If you find that some service is not working, look at what sort of
packet is being LOGged, and then add an ACCEPT rule to allow that type of
packet. That will allow you to get your ruleset allowing the traffic you
want without necessarily having to look up too much detail about what the traffic is in advance (such as the security update feature I asked about above - I don't know what that uses, so if you don't either, just run it, see what packet type gets LOGged before being DROPped, and then ACCEPT that sort of packet).
Regards,
Antony.
Signature · 6 lines
Having been asked for a reference for this man,
I can confirm that you will be very lucky indeed if you can get him to work
for you.
Please reply to the list;
please don't CC me.-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dear all,
I got a problem dealing with my current iptables rules
here is my iptables rules:-
$ipt -A FORWARD -i $EXT -o $DMZ -p tcp -m tcp -s 0/0 -d $WEB --dport 80
- -j LOG --log-level info --log-prefix "[IN WEB] :"
$ipt -A FORWARD -i $EXT -o $DMZ -p tcp -m tcp -s 0/0 -d $WEB --dport 80
- -j ACCEPT
$ipt -A FORWARD -i ! $EXT -m state --state NEW -j ACCEPT $ipt -A FORWARD -i $EXT -m state --state ESTABLISHED,RELATED -j LOG
- --log-prefix "Established conn: "
$ipt -A FORWARD -i $EXT -m state --state ESTABLISHED,RELATED -j ACCEPT $ipt -A FORWARD -i $EXT -o $DMZ -p tcp -m tcp ! --tcp-flags SYN,RST,ACK SYN -m state --state NEW -j LOG --log-prefix "NEW NOT SYN: " $ipt -A FORWARD -i $EXT -o $DMZ -p tcp -m tcp ! --tcp-flags SYN,RST,ACK SYN -m state --state NEW -j DROP
$ipt -A FORWARD -i $EXT -o $DMZ -p tcp -j LOG --log-level info
- --log-prefix " EXT-DMZ TCP DROP "
$ipt -A FORWARD -i $EXT -o $DMZ -p tcp -j REJECT $ipt -A FORWARD -i $DMZ -o $EXT -p tcp -j LOG --log-level info
- --log-prefix " DMZ-EXT TCP DROP "
$ipt -A FORWARD -i $DMZ -o $EXT -p tcp -j REJECT $ipt -A FORWARD -i $EXT -o $DMZ -p udp -j LOG --log-level info
- --log-prefix " EXT-DMZ UDP DROP "
$ipt -A FORWARD -i $EXT -o $DMZ -p udp -j REJECT $ipt -A FORWARD -i $DMZ -o $EXT -p udp -j LOG --log-level info
- --log-prefix " DMZ-EXT UDP DROP "
$ipt -A FORWARD -i $DMZ -o $EXT -p udp -j REJECT
so my problem is why ppl outside can't browse my webpages?
so here is the logApr 4 18:30:33 gatekeeper kernel: [IN WEB] :IN=eth0 OUT=eth2 SRC=yyyy DST=xxxx LEN=52 TOS=0x00 PREC=0x60 TTL=48 ID=43502 DF PROTO=TCP SPT=31633 DPT=80 WINDOW=17376 RES=0x00 ACK FIN URGP=0
Apr 4 18:30:33 gatekeeper kernel: DMZ-EXT TCP DROP IN=eth2 OUT=eth0
SRC=xxxx DST=yyyy LEN=52 TOS=0x00 PREC=0x00 TTL=63 ID=47448 DF PROTO=TCP SPT=80 DPT=31633 WINDOW=17376 RES=0x00 ACK URGP=0
why the next rule keep blocking the packets? did the iptables support statefull connection?
i don't even see this problem if using pf (openbsd), so did anyone here can solve out my problem??
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAcMs+nnQOtAme0WcRAi7oAJ46DyS3NuilYjHQoWeAuUiCDm3N6gCfdl9C plHh7522RwTppWOzUlAUOf8=
=w3V0
-----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Antony Stone wrote:
| | Because you are REJECTing the reply packets from the server :) | | Just take a look at the above rules, and think firstly about a SYN packet from | the client (EXT) to the server (on the DMZ). | | It will match the first and second rules, and therefore gets LOGged, and | ACCEPTed. | | Now think about the SYN ACK replly packet from the server (on the DMZ) to the | client (EXT). | | It will match the tenth and eleventh rules, and therefore gets LOGged and | REJECTed. | | Hope this explains the problem. | | Regards, | | Antony. |
i still can't figure out, if i modified the rule then add this entry, ppl on my web (got shell access) can go anywhere.
$ipt -A SCAN -i $DMZ -o $EXT -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN
- -m state --state NEW -j REJECT
That's not what i want, what i need is my web server can serve ppl from outside but fw denied any new connections from the web server to outside. for example using pf
block in on fxp0 from any to any
pass in on fxp0 inet proto tcp from any to web port=80 keep state block out log on fxp0 from $web to any
thanks in advance... and please advice :-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAcOC3nnQOtAme0WcRAnInAJ9wj/sooPdpQlb1k3+Q1XSrLK6ATwCfbqR1 EfBjVnlHZN7Sn6GtWrKeu5s=
=HMdw
-----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
|>Antony Stone wrote:
|
| I suggest you add a rule allowing ESTABLISHED,RELATED (but not NEW) packets
| from the DMZ to EXT. That will allow replies but no new connections. | | However, I also suggest you think very carefully about not allowing NEW | connections from your web server to the outside world - specifically in | relation to DNS - are you sure the web server itself never needs to do | external lookups (perhaps for visitor logs etc)? So long as this is
true,
| you'll be okay, but I think you should keep an eye on your netfilter log | entries to see if the web server is trying to make some external connections
| which you actually decide you want to allow. | | Regards, | | Antony. |
already did that and it's work.. thanks.. but somehow i would like to allow my web for updating security patches from xxxx server, but the fw have rejected the req.
here is my rules:-
$ipt -A SCAN -i $EXT -o $DMZ -p tcp -m tcp -s 0/0 -d $WEB --dport 80 -j LOG --log-level info --log-prefix "[IN WEB] :"
$ipt -A SCAN -i $EXT -o $DMZ -p tcp -m tcp -s 0/0 -d $WEB --dport 80 -j ACCEPT
$ipt -A SCAN -i $EXT -m state --state ESTABLISHED,RELATED -j LOG
- --log-prefix "Established conn: "
$ipt -A SCAN -i $EXT -m state --state ESTABLISHED,RELATED -j ACCEPT $ipt -A SCAN -i $EXT -o $DMZ -p tcp -m tcp ! --tcp-flags SYN,RST,ACK SYN -m state --state NEW -j LOG --log-prefix "NEW NOT SYN: " $ipt -A SCAN -i $EXT -o $DMZ -p tcp -m tcp ! --tcp-flags SYN,RST,ACK SYN -m state --state NEW -j DROP
$ipt -A FORWARD -i $DMZ -p tcp -m state --state NEW -s $WEB -d xxxx
- --dport 80 -j LOG --log-level info --log-prefix "OUT DNS :" $ipt -A FORWARD -i $DMZ -p tcp -m state --state NEW -s $WEB -d xxxx
- --dport 80 -j ACCEPT
$ipt -A FORWARD -i $DMZ -o $EXT -p tcp -m tcp -m state --state NEW -j LOG --log-level info --log-prefix "[Init DMZ] "
$ipt -A FORWARD -i $DMZ -o $EXT -p tcp -m tcp -m state --state NEW -j REJECT
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAcRBInnQOtAme0WcRAmcmAJ984xfpZiOX0icdK3/vwWn9boVZRgCeKeiX znZp8xcWxMoN+XDYh9LZ5u0=
=1Lj9
-----END PGP SIGNATURE-----