This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Help Understanding Firewall Block Rules

Environment:

test_vm (192.168.0.123)
astaro (192.168.0.1)

Goal: Block incoming traffic from a specific internet IP.  For this example, I'm using HTTP traffic to keep it simple, but it could be anything)

If I setup a rule as follows:

source - test_vm
services - http (src_port 1:65535; dest_port: 80)
destination - internet
action - reject

Web browsing is blocked and I can see the page requests being blocked in the firewall log (this is expected).

If I reverse the rule (to block the responses, not the requests)
source - internet
services - http response (src_port 80; dest_port: 1:65535)
destination - test_vm
action - reject

Web browsing is fully functional and the firewall doesn't stop the traffic.  This same behavior occurs with other traffic such as DNS reponses as well.  Can someone explain to me why this is?  As far as I can tell, that rule should block all traffic originating from port 80 to my test_vm.


This thread was automatically locked due to age.
Parents
  • Öööhhmm - that sounds strange. With ONLY rule2 enabled it should not be possible to browse the web. Do you see the pakets in the paketfilterlog if you have only rule2 enabled? Do you have any other rules in your setup that allows http (or ANY) traffic? Can the test_vm somehow bypass your ASG?

    Concerning the stateful question - google or wikipedia are your friends ;-). I think almost all modern firewall systems work that way (please correct me if I'm wrong...).

    Concerning your goal mentioned in post 1: If you have no rule that allows incoming traffic from inet to internal - it is blocked by default. If you have a rule or a DNAT with autorule enabled, then there could be a need to do so - maybe you can describe your setup a little more detailed.

    Regards
    Manfred
Reply
  • Öööhhmm - that sounds strange. With ONLY rule2 enabled it should not be possible to browse the web. Do you see the pakets in the paketfilterlog if you have only rule2 enabled? Do you have any other rules in your setup that allows http (or ANY) traffic? Can the test_vm somehow bypass your ASG?

    Concerning the stateful question - google or wikipedia are your friends ;-). I think almost all modern firewall systems work that way (please correct me if I'm wrong...).

    Concerning your goal mentioned in post 1: If you have no rule that allows incoming traffic from inet to internal - it is blocked by default. If you have a rule or a DNAT with autorule enabled, then there could be a need to do so - maybe you can describe your setup a little more detailed.

    Regards
    Manfred
Children
  • Do you see the pakets in the paketfilterlog if you have only rule2 enabled? Do you have any other rules in your setup that allows http (or ANY) traffic? Can the test_vm somehow bypass your ASG?


    I do not see any hits for rule 2 in the firewall logs when it is enabled.

    My other rules are below rule 1&2 which should mean if they're caught by a previous rule, the latter rules don't apply.  They are as follows:

    Firewall
    ==============================
    Rule 1
    Rule 2
    Allow: Internal network -> Any
    Allow: VPN Pool (Custom PPTP) -> Internet IPv4
    Allow: VPN Pool (Custom PPTP) -> Internal (network)
    Allow: Internal (Network) -> VPN Pool (Custom PPTP) [I guess this one is a bit redundant, but I wanted to have it in place in case I ever change the internal network->any rule to something more specific]

    NAT
    ==============================
    Masquerading
    -------------------------------
    Internal Network -> External (WAN)
    VPN Pool (Custom PPTP) -> External (WAN)

    NAT
    -------------------------------
    A bunch of port forwards for various non-http services from any->my server
    3 full NAT rules to reflect my WAN ip to my local clients (1 is for a local webserver).
    That rule is:

    Rule Type: Full NAT
    Matching Condition:
    For traffic from: internal network
    using service: http
    going to: external (WAN Address)
    Action: Change the destination to: my server
    Action: Change the source to: internal (Address)


    What is the relationship between "unsolicited" incoming traffic and incoming traffic that is in response to an outgoing request going through NAT via a masquerading rule?  Once that NAT "session" gets mapped, how is incoming traffic treated for that port?  Does it bypass the firewall (and hence bypass rule 2)?  This seems more like a NAT issue to me than a Stateful Firewall issue.
  • OK - as far as I understand rule#3 allows the outgoing traffic for your test_vm.

    I think the full nat rules are not needed as the masq rule will translate your internal ip's to your external ip. If you have enabled the autopaketfilter checkbox in the NAT's you will not see every paket that match this rule in the pf log - thats 'normal behavior' for these hidden rules. Personally I don't like these hidden rules and I create the necessary pf rules manually. 

    But to be honest - I still don't get it what the real problem is. Your idea how to block incoming traffic from a specific ip is ok as long as you don't use incoming NATs with autopaketfilter checked. There is a sequence how pakets are processed by the ASG: DNAT - Proxys - Paketfilter - SNAT and if a paket is treated by a DNAT with autopaketfilter checked no manual paketfilterrule is considered.

    The difference between "unsolicited" incoming traffic and incoming traffic that is in response to an outgoing request is that the latter pakets are alowed because the ASG tracks the initiated outgoing sessions and allows the answer pakets for these sessions (it's done by session not by port..).

    Regards
    Manfred
  • OK - as far as I understand rule#3 allows the outgoing traffic for your test_vm.


    That is correct.  As this is a home network, all outbound traffic is allowed unless specifically blocked (as in what we are calling "rule 1")



    I think the full nat rules are not needed as the masq rule will translate your internal ip's to your external ip. 


    The full nat rules allow me to point computers on the LAN to my external domain name to access services.  For example, if my domain name is mydomain.com instead of having to point my local clients at http://server1 I can point them to mydomain.com  

    That tip was given to me here: http://www.astaro.org/astaro-gateway-products/network-security-firewall-nat-qos-ips/43325-nat-reflection.html

    That however is working as expected, so no problem there.


    If you have enabled the autopaketfilter checkbox in the NAT's you will not see every paket that match this rule in the pf log - thats 'normal behavior' for these hidden rules. Personally I don't like these hidden rules and I create the necessary pf rules manually. 


    There are no NAT rules for test_vm, only for my other machines on the network.  The only nat rule that applies to test_vm is the internal(network)->external (WAN) masquerading rule that makes nat work for all my LAN machines.


    But to be honest - I still don't get it what the real problem is. Your idea how to block incoming traffic from a specific ip is ok as long as you don't use incoming NATs with autopaketfilter checked. There is a sequence how pakets are processed by the ASG: DNAT - Proxys - Paketfilter - SNAT and if a paket is treated by a DNAT with autopaketfilter checked no manual paketfilterrule is considered.


    The "problem" if you really want to call it that (this is just a test situation to learn how the firewall behaves) is if creating a firewall rule that blocks traffic from test_vm;ports 1:65535 -> internet ip;port 80 blocks outgoing requests, why dose a firewall rule set to block traffic from internet ip;port 80 ->  test_vm;ports 1:65535 not do the same thing?  I would the reversed rule to allow responses out to a web server on the internet but not allow the responses back to test_vm (but they DO make it back for some reason that I am trying to figure out).


    The difference between "unsolicited" incoming traffic and incoming traffic that is in response to an outgoing request is that the latter packets are allowed because the ASG tracks the initiated outgoing sessions and allows the answer pakets for these sessions (it's done by session not by port..).


    Do the packetfilter rules (specifically blocks) not apply to "responses" for allowed outbound traffic?  Theoretically if a block outgoing request rule works, I can't see why reversing it and blocking incoming responses wouldn't work unless the firewall rules don't apply to responses.
  • OK - I got it :-).

    I think you can't block the answer pakets for an initiated session (..for what sense..??). If you would use a non-stateful firewall, you would have to define separate rules for the answer pakets and if you forget that, the communication will not work :-) - but thats not the way ASG works. Here this is described in the history section.

    Regards
    Manfred