OPNsense Forum

International Forums => German - Deutsch => Topic started by: ole on May 31, 2020, 02:44:44 pm

Title: Meine Firewall Regel killt die SSH Verbindung
Post by: ole on May 31, 2020, 02:44:44 pm
Hallo Opnsense Freunde,

offenbar habe ich ein echtes Problem mit dem Verstehen der Firewall rules (oder/und mir fehlt der Background).

Ich habe per VLAN ein Mgmt Netz aufgebaut und bekomme nach kurzer Zeit Verbindungsabbrüche, die sich mit den Tips aus dem INet (KeepAlive... etc.) nicht lösen lassen. Inzwischen kam ich auf die Idee, die FW Regeln mal loggen zu lassen. Für mich sehen die Regeln ok aus, das Log sagt aber etwas anderes, siehe mgmt_RULES.png

Aktive Rules sind #1 und #2

Pass: IPv{4,6} Source Mgmt Network any Port -> Opnsense Mgmt Network IP any port
Pass: IPv{4,6} Source Mgmt Network any Port -> any IP im Mgmt Network any port

ursprünglich sollte der Verkehr aus dem Mgmt Net in andere Netze zudem geblockt werden - was die default block Rule auch macht, wie ich inzwischen im Log gesehen habe.

Das Log sieht dann so aus mgmt_LOG.png.

Die Verbindung von meinem Host 192.168.10.100 nach 192.168.10.11:22 wird aufgebaut und eine Weile gehalten, dann wird geblockt was das Zeug hält. Das war nicht so beabsichtigt und erklärt meine Abbrüche mit der SSH Verbindung.

Wo ist meine Wissenslücke/Denkfehler und wie bekomme ich meine SSH Verbindung wieder hin ohne alles "offen" zu haben? Ich gehe davon aus, das Mgmt Traffic auch in diesem Netzt bleiben soll ...

Vielen Dank

Title: Re: Meine Firewall Regel killt die SSH Verbindung
Post by: hbc on May 31, 2020, 05:44:32 pm
Also spontan kann ich schon mal sagen, das Regel 1 überflüssig ist,  denn Management Adress liegt ja in Management net.

Was im Log seltsam ist, ist das "let anything out from firewall", da die Source IP (.100) doch gar nicht deine Firewall (.11) ist
Title: Re: Meine Firewall Regel killt die SSH Verbindung
Post by: banym on May 31, 2020, 07:15:52 pm
Hallo,
bitte mach doch mal einen Netzplan und mehr Infos dazu wie du die VLANs und die Firewall konfiguriert hast.

Title: Re: Meine Firewall Regel killt die SSH Verbindung
Post by: ole on May 31, 2020, 07:42:00 pm
Also spontan kann ich schon mal sagen, das Regel 1 überflüssig ist,  denn Management Adress liegt ja in Management net.

Danke für die Antwort, ich hatte es fast befürchtet, ich werde sie rauswerfen.

Was im Log seltsam ist, ist das "let anything out from firewall", da die Source IP (.100) doch gar nicht deine Firewall (.11) ist

evtl. ist das das Ergebnis obiger Rule? Ich werfe sie erst'mal raus und probiere neu.
Später: Nun, hat nichts gebracht. Selbst das "Scheunentor" "Allow all for SSH" hat nicht gewirkt.

https://www.reddit.com/r/PFSENSE/comments/611viz/odd_log_let_out_anything_from_firewall_host_itself/ (https://www.reddit.com/r/PFSENSE/comments/611viz/odd_log_let_out_anything_from_firewall_host_itself/) hat zumindest eine Erklärung bzgl. der "let anything out from firewall" rule (was ich dennoch nicht genau verstehe mit dem Zusammenhang der SSH). Der RID link davon geht auch in's Nirvana. Clear States hat auch nichts gebracht :( Der OPNsense health check war erfolgreich, also scheinbar nichts gehackt (hätte mich auch gewundert, da keine Dienste im INet). So, eben gefunden - es ist eine Auto Floating rule.

Angehängt nochmals das Log mit Filter, einschl. OPNsense IP. Evtl. ist noch wichtig:

Meine Box:
Code: [Select]
$ ip r
default via 192.168.1.1 dev enp5s0 proto dhcp metric 100
192.168.1.0/24 dev enp5s0 proto kernel scope link src 192.168.1.100 metric 100
192.168.10.0/24 dev enp5s0.10 proto kernel scope link src 192.168.10.100 metric 400
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown

Die andere, die zu erreichen versuche (mit Docker und libvirt):
Code: [Select]
$ ip r
default via 192.168.90.1 dev dmz proto static
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
172.19.0.0/16 dev br-72ec11bd3bd8 proto kernel scope link src 172.19.0.1 linkdown
172.21.0.0/16 dev br-7c5fe20dbe79 proto kernel scope link src 172.21.0.1
172.22.0.0/16 dev br-f5beb4943ad7 proto kernel scope link src 172.22.0.1
172.23.0.0/16 dev br-ba2d4fbb272e proto kernel scope link src 172.23.0.1 linkdown
172.24.0.0/16 dev br-973649b6bd6e proto kernel scope link src 172.24.0.1
192.168.10.0/24 dev mgmt proto kernel scope link src 192.168.10.11
192.168.10.0/24 via 192.168.10.1 dev mgmt proto static
192.168.90.0/24 dev dmz proto kernel scope link src 192.168.90.11
192.168.203.0/24 dev br-e24f9101744b proto kernel scope link src 192.168.203.1

mit 192.168.10.0/24 VLAN tag=10 bzw. 192.168.90.0/24 tag=90

und meine Regeln mit Netzplan (siehe Anhang):

Code: [Select]
sudo pfctl -sr
scrub on lo0 all fragment reassemble
scrub on igb2_vlan90 all fragment reassemble
scrub on igb1_vlan20 all fragment reassemble
scrub on igb1 all fragment reassemble
scrub on igb1_vlan10 all fragment reassemble
scrub on igb0 all fragment reassemble
block drop in log on ! igb2_vlan90 inet from 192.168.90.0/24 to any
block drop in log inet from 192.168.90.1 to any
block drop in log on ! igb1_vlan20 inet from 192.168.20.0/24 to any
block drop in log inet from 192.168.20.1 to any
block drop in log on ! igb1 inet from 192.168.1.0/24 to any
block drop in log inet from 192.168.1.1 to any
block drop in log on ! igb1_vlan10 inet from 192.168.10.0/24 to any
block drop in log inet from 192.168.10.1 to any
block drop in log on ! igb0 inet from 192.168.0.0/24 to any
block drop in log inet from 192.168.0.111 to any
block drop in log on igb1_vlan20 inet6 from fe80::20d:b9ff:fe52:f725 to any
block drop in log on igb1 inet6 from fe80::20d:b9ff:fe52:f725 to any
block drop in log on igb1_vlan10 inet6 from fe80::20d:b9ff:fe52:f725 to any
block drop in log on igb2_vlan90 inet6 from fe80::20d:b9ff:fe52:f726 to any
block drop in log on igb0 inet6 from fe80::20d:b9ff:fe52:f724 to any
block drop in log inet all label "02f4bab031b57d1e30553ce08e0ec131"
block drop in log inet6 all label "02f4bab031b57d1e30553ce08e0ec131"
pass in log quick inet6 proto ipv6-icmp all icmp6-type unreach keep state label "1d245529367b2e34eeaff16086aeafe9"
pass in log quick inet6 proto ipv6-icmp all icmp6-type toobig keep state label "1d245529367b2e34eeaff16086aeafe9"
pass in log quick inet6 proto ipv6-icmp all icmp6-type neighbrsol keep state label "1d245529367b2e34eeaff16086aeafe9"
pass in log quick inet6 proto ipv6-icmp all icmp6-type neighbradv keep state label "1d245529367b2e34eeaff16086aeafe9"
pass out log quick inet6 proto ipv6-icmp from (self) to fe80::/10 icmp6-type echorep keep state label "12191c6b3ba42170cae851ee417ac720"
pass out log quick inet6 proto ipv6-icmp from (self) to ff02::/16 icmp6-type echorep keep state label "12191c6b3ba42170cae851ee417ac720"
pass out log quick inet6 proto ipv6-icmp from (self) to fe80::/10 icmp6-type routersol keep state label "12191c6b3ba42170cae851ee417ac720"
pass out log quick inet6 proto ipv6-icmp from (self) to ff02::/16 icmp6-type routersol keep state label "12191c6b3ba42170cae851ee417ac720"
pass out log quick inet6 proto ipv6-icmp from (self) to fe80::/10 icmp6-type routeradv keep state label "12191c6b3ba42170cae851ee417ac720"
pass out log quick inet6 proto ipv6-icmp from (self) to ff02::/16 icmp6-type routeradv keep state label "12191c6b3ba42170cae851ee417ac720"
pass out log quick inet6 proto ipv6-icmp from (self) to fe80::/10 icmp6-type neighbrsol keep state label "12191c6b3ba42170cae851ee417ac720"
pass out log quick inet6 proto ipv6-icmp from (self) to ff02::/16 icmp6-type neighbrsol keep state label "12191c6b3ba42170cae851ee417ac720"
pass out log quick inet6 proto ipv6-icmp from (self) to fe80::/10 icmp6-type neighbradv keep state label "12191c6b3ba42170cae851ee417ac720"
pass out log quick inet6 proto ipv6-icmp from (self) to ff02::/16 icmp6-type neighbradv keep state label "12191c6b3ba42170cae851ee417ac720"
pass in log quick inet6 proto ipv6-icmp from fe80::/10 to fe80::/10 icmp6-type echoreq keep state label "42e9d787749713a849d8e92432efdfaa"
pass in log quick inet6 proto ipv6-icmp from fe80::/10 to ff02::/16 icmp6-type echoreq keep state label "42e9d787749713a849d8e92432efdfaa"
pass in log quick inet6 proto ipv6-icmp from fe80::/10 to fe80::/10 icmp6-type routersol keep state label "42e9d787749713a849d8e92432efdfaa"
pass in log quick inet6 proto ipv6-icmp from fe80::/10 to ff02::/16 icmp6-type routersol keep state label "42e9d787749713a849d8e92432efdfaa"
pass in log quick inet6 proto ipv6-icmp from fe80::/10 to fe80::/10 icmp6-type routeradv keep state label "42e9d787749713a849d8e92432efdfaa"
pass in log quick inet6 proto ipv6-icmp from fe80::/10 to ff02::/16 icmp6-type routeradv keep state label "42e9d787749713a849d8e92432efdfaa"
pass in log quick inet6 proto ipv6-icmp from fe80::/10 to fe80::/10 icmp6-type neighbrsol keep state label "42e9d787749713a849d8e92432efdfaa"
pass in log quick inet6 proto ipv6-icmp from fe80::/10 to ff02::/16 icmp6-type neighbrsol keep state label "42e9d787749713a849d8e92432efdfaa"
pass in log quick inet6 proto ipv6-icmp from fe80::/10 to fe80::/10 icmp6-type neighbradv keep state label "42e9d787749713a849d8e92432efdfaa"
pass in log quick inet6 proto ipv6-icmp from fe80::/10 to ff02::/16 icmp6-type neighbradv keep state label "42e9d787749713a849d8e92432efdfaa"
pass in log quick inet6 proto ipv6-icmp from ff02::/16 to fe80::/10 icmp6-type echoreq keep state label "8752fca75c6be992847ea984161bd3f1"
pass in log quick inet6 proto ipv6-icmp from ff02::/16 to fe80::/10 icmp6-type routersol keep state label "8752fca75c6be992847ea984161bd3f1"
pass in log quick inet6 proto ipv6-icmp from ff02::/16 to fe80::/10 icmp6-type routeradv keep state label "8752fca75c6be992847ea984161bd3f1"
pass in log quick inet6 proto ipv6-icmp from ff02::/16 to fe80::/10 icmp6-type neighbrsol keep state label "8752fca75c6be992847ea984161bd3f1"
pass in log quick inet6 proto ipv6-icmp from ff02::/16 to fe80::/10 icmp6-type neighbradv keep state label "8752fca75c6be992847ea984161bd3f1"
pass in log quick inet6 proto ipv6-icmp from :: to ff02::/16 icmp6-type echoreq keep state label "71dd196398b3f1da265dbd9dcad00e70"
pass in log quick inet6 proto ipv6-icmp from :: to ff02::/16 icmp6-type routersol keep state label "71dd196398b3f1da265dbd9dcad00e70"
pass in log quick inet6 proto ipv6-icmp from :: to ff02::/16 icmp6-type routeradv keep state label "71dd196398b3f1da265dbd9dcad00e70"
pass in log quick inet6 proto ipv6-icmp from :: to ff02::/16 icmp6-type neighbrsol keep state label "71dd196398b3f1da265dbd9dcad00e70"
pass in log quick inet6 proto ipv6-icmp from :: to ff02::/16 icmp6-type neighbradv keep state label "71dd196398b3f1da265dbd9dcad00e70"
block drop in log quick inet proto tcp from any port = 0 to any label "7b5bdc64d7ae74be1932f6764a591da5"
block drop in log quick inet proto udp from any port = 0 to any label "7b5bdc64d7ae74be1932f6764a591da5"
block drop in log quick inet6 proto tcp from any port = 0 to any label "7b5bdc64d7ae74be1932f6764a591da5"
block drop in log quick inet6 proto udp from any port = 0 to any label "7b5bdc64d7ae74be1932f6764a591da5"
block drop in log quick inet proto tcp from any to any port = 0 label "ae69f581dc429e3484a65f8ecd63baa5"
block drop in log quick inet proto udp from any to any port = 0 label "ae69f581dc429e3484a65f8ecd63baa5"
block drop in log quick inet6 proto tcp from any to any port = 0 label "ae69f581dc429e3484a65f8ecd63baa5"
block drop in log quick inet6 proto udp from any to any port = 0 label "ae69f581dc429e3484a65f8ecd63baa5"
block drop in log quick proto carp from (self) to any label "306de368b07e5782660745341cd22731"
pass log quick proto carp all keep state label "ace7acc1be88f3baee3b75f64fca8a6f"
block drop in log quick proto tcp from <sshlockout> to (self) port = ssh label "669143f420c3ab4118bcb0bf4b5fd823"
block drop in log quick proto tcp from <webConfiguratorlockout> to (self) port = https label "6a62150c9c4144fd91303bb801c1d682"
block drop in log quick from <virusprot> to any label "8e367e2f9944d93137ae56d788c5d5e1"
block drop in log quick on igb0 inet from <bogons> to any label "b7cd97a164650b538506fb551a0369e7"
block drop in log quick on igb0 inet6 from <bogonsv6> to any label "f140a48ddade668b9d6f5259669a1d5c"
block drop in log quick on igb0 inet from 10.0.0.0/8 to any label "1eb94a38e58994641aff378c21d5984f"
block drop in log quick on igb0 inet from 127.0.0.0/8 to any label "1eb94a38e58994641aff378c21d5984f"
block drop in log quick on igb0 inet from 100.64.0.0/10 to any label "1eb94a38e58994641aff378c21d5984f"
block drop in log quick on igb0 inet from 172.16.0.0/12 to any label "1eb94a38e58994641aff378c21d5984f"
block drop in log quick on igb0 inet from 192.168.0.0/16 to any label "1eb94a38e58994641aff378c21d5984f"
block drop in log quick on igb0 inet6 from fc00::/7 to any label "45afd72424c84d011c07957569151480"
pass in log quick on igb1_vlan20 inet proto udp from any port = bootpc to 255.255.255.255 port = bootps keep state label "102fc1c757023ef7f945d512ed212862"
pass in log quick on igb1_vlan20 proto udp from any port = bootpc to (self) port = bootps keep state label "09ef23f01c5890e379d587e8e2d3dea0"
pass out log quick on igb1_vlan20 proto udp from (self) port = bootps to any port = bootpc keep state label "4d95e0fbab26f616dedb0dda7c7581c3"
pass in log quick on igb1 inet proto udp from any port = bootpc to 255.255.255.255 port = bootps keep state label "5168be2cca1e130b1ef2ac18161356a8"
pass in log quick on igb1 proto udp from any port = bootpc to (self) port = bootps keep state label "0b032d1bab91fc97e4a7faf03a7f17c3"
pass out log quick on igb1 proto udp from (self) port = bootps to any port = bootpc keep state label "5039e43005a9aa50eb032af274cc9aad"
pass in log quick on igb1_vlan10 inet proto udp from any port = bootpc to 255.255.255.255 port = bootps keep state label "07daf606e4baa82915478774a40f014d"
pass in log quick on igb1_vlan10 proto udp from any port = bootpc to (self) port = bootps keep state label "1e13125d68d267924569eadb69fa1ad1"
pass out log quick on igb1_vlan10 proto udp from (self) port = bootps to any port = bootpc keep state label "4eb553ee95bcbf5299054b24b13f5528"
pass in log on igb0 proto udp from any port = bootps to any port = bootpc keep state label "613fb331c903de9502461c121104e092"
pass out log on igb0 proto udp from any port = bootpc to any port = bootps keep state label "b8e1da9ac60ce8edb8e5a84bc5cec53e"
pass in log quick on lo0 all flags S/SA keep state label "59162224cde3be673a9b295d6e24dcea"
pass out log all flags S/SA keep state allow-opts label "fae559338f65e11c53669fc3642c93c2"
pass in log quick on igb1 proto tcp from any to (self) port = ssh flags S/SA keep state label "bb72618316fdf630cdf15f33ae3d699f"
pass in log quick on igb1 proto tcp from any to (self) port = http flags S/SA keep state label "bb72618316fdf630cdf15f33ae3d699f"
pass in log quick on igb1 proto tcp from any to (self) port = https flags S/SA keep state label "bb72618316fdf630cdf15f33ae3d699f"
pass out log route-to (igb0 192.168.0.1) inet from 192.168.0.111 to ! (igb0:network) flags S/SA keep state allow-opts label "cd93fefa18691a23a58dfb8426bd1580"
pass in quick on igb1 inet all flags S/SA keep state label "e1ab4a00ed393b2dc50b0764aeedb48b"
pass in log quick on igb1_vlan10 inet from (igb1_vlan10:network) to (igb1_vlan10:network) flags S/SA keep state label "b95644be84486554a62811a3cb9402f9"
pass in log quick on igb1_vlan10 inet6 from (igb1_vlan10:network) to (igb1_vlan10:network) flags S/SA keep state label "b95644be84486554a62811a3cb9402f9"
pass in log quick on igb1_vlan10 inet all flags S/SA keep state label "8334951b3a74854c626762def18eb0ad"
pass in log quick on igb1_vlan10 inet6 all flags S/SA keep state label "8334951b3a74854c626762def18eb0ad"
pass in quick on igb2_vlan90 inet from any to (igb1:network) flags S/SA keep state label "816c08c7f93db97cd205edec9a2b15de"
pass in quick on igb2_vlan90 inet6 from any to (igb1:network) flags S/SA keep state label "816c08c7f93db97cd205edec9a2b15de"
pass in quick on igb2_vlan90 inet from any to (igb1_vlan20:network) flags S/SA keep state label "21afbf6da5f269e46338ecc8afe97957"
pass in quick on igb2_vlan90 inet6 from any to (igb1_vlan20:network) flags S/SA keep state label "21afbf6da5f269e46338ecc8afe97957"
pass in quick on igb2_vlan90 inet from any to ! <RFC1918> flags S/SA keep state label "789292898ab459823690a5edae1af13c"
pass in quick on igb2_vlan90 inet6 from any to ! <RFC1918> flags S/SA keep state label "789292898ab459823690a5edae1af13c"
pass in quick on igb1_vlan20 inet all flags S/SA keep state label "bb70c0b3dc0eabeea150752cedb5c539"
pass in quick on igb1_vlan20 inet6 all flags S/SA keep state label "bb70c0b3dc0eabeea150752cedb5c539"
anchor "iperf" all
Title: Re: Meine Firewall Regel killt die SSH Verbindung
Post by: hbc on May 31, 2020, 10:39:12 pm
Weil ich gerade die sshlockout rule sehe. Hast Du SSH und WebGUI überhaupt an dein Management Interface gebunden?
Muss ja, braucht ja nur ab, wird also aufgebaut.

Title: Re: Meine Firewall Regel killt die SSH Verbindung
Post by: ole on June 01, 2020, 12:33:07 pm
anbei die OPNsense SSH settings, falls relevant
Title: Re: Meine Firewall Regel killt die SSH Verbindung
Post by: ole on June 01, 2020, 05:05:25 pm
was ich eben noch beim Durchsehen meiner Regeln gefunden habe - siehe Anhang. LAN1 ist das default/ursprüngliche LAN von der Ersteinrichtung. Ich denke, es ist eine Auto Rule, da ich mich nicht erinnern kann sie angelegt zu haben. Es betrifft aber die OPNsense ports. Der Zweck/Anwendungsfall erschließt sich mir aber nicht so ganz.
Title: Re: Meine Firewall Regel killt die SSH Verbindung
Post by: micneu on June 02, 2020, 06:18:49 am
Das ist eine Regel die immer eingerichtet wird, damit du immer vom lan auf die Sense kommst


Gesendet von iPhone mit Tapatalk Pro
Title: Re: Meine Firewall Regel killt die SSH Verbindung
Post by: ole on June 02, 2020, 05:49:24 pm
Das ist eine Regel die immer eingerichtet wird, damit du immer vom lan auf die Sense kommst

verstehe es so richtig, dass kein NAT von OPNsense's Ports 22,80,433 so möglich ist?

Bzgl. dem SSH Problem: Ist asymetric routing möglicherweise verantwortlich dafür? Ich habe auf beiden PC nur ein NIC mit je 2 Interfaces mit entsprechenden Gateways. PC#1 IP/GW auf LAN1 und Mgmt, PC#2 IP/GW auf DMZ und Mgmt. Netzwerk Einstellungen siehe oben. Mit dem Anlegen einer statischen Route bin ich mir auch total unklar aufgrund fehlenden Wissens.

Ich sehe mit Wireshark auf dem PC#1 Traffic (fedora captive portal test, Dropbox LAN sync, ...) auf dem Mgmt Netz der dafür gar nicht vorgesehen ist, trotz default gateway auf dem LAN1 Netzwerk. Imo wäre das gleiche Problem auch mit 2 NICs.

Nachtrag:

Es liegt an den Netzwerk-Einstellungen von meinem PC#1. Ich habe an den Switch Port 5 (siehe oben Netzplan) Mgmt LAN untagged einen PC#3 angeschlossen. Dieser hat per DHCP die IP bekommen. SSH funktioniert wie erwartet:

Code: [Select]
$ ip a
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether c0:3f:d5:66:d0:6d brd ff:ff:ff:ff:ff:ff
    altname enp0s25
    inet 192.168.10.101/24 brd 192.168.10.255 scope global dynamic noprefixroute eno1
       valid_lft 6807sec preferred_lft 6807sec

$ ip -d link show eno1
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether c0:3f:d5:66:d0:6d brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 9000 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
    altname enp0s25

$ ip r
default via 192.168.10.1 dev eno1 proto dhcp metric 100
192.168.10.0/24 dev eno1 proto kernel scope link src 192.168.10.101 metric 100
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown

$ nmcli device
DEVICE      TYPE      STATE        CONNECTION
eno1        ethernet  connected    eno1       
virbr0      bridge    connected    virbr0     
wlp2s0      wifi      unavailable  --         
lo          loopback  unmanaged    --         
virbr0-nic  tun       unmanaged    --         
Title: Re: Meine Firewall Regel killt die SSH Verbindung
Post by: ole on June 03, 2020, 08:36:19 pm
Ziemlich unbefriedigend, aber wahr. Ich habe mit dem NetworkManager nmcli hin- und her probiert, meiner APU das aktuelle BIOS spendiert, alles neu gestartet und nun - klappt es anscheinend ... Dennoch vielen Dank für die Hinweise/Hilfe.