Verständnisproblem oder Fehlkonfiguration / Schlimmeres

Started by mcdaniels, December 29, 2023, 09:27:48 AM

Previous topic - Next topic
Hallo zusammen,
ich bin bzgl. Opnsense komplett neu und stehe hier vor einem Problem, das ich nicht gelöst bekomme, weil ich das Verhalten der Firewall offenbar nicht verstehe.

Situation:
2 WAN Ports (WAN und WAN2)
Jedes dieser Ports hat eine eindeutige, statische öffentl. IP

Eine DMZ mit 2 Webservern (testhalber)
Webserver 1: 192.168.1.5
Webserver 2: 192.168.1.15

Wenn ich nun ein NAT - Portforwarding erstelle:
Interface WAN
Proto: TCP
Src-Addr: *
Src-Ports: *
Dst-Address: WAN1
Dst-Port: 80

NAT

IP: 192.168.1.5
Port: 80

funktioniert dies eine Zeit lang. Aus für mich unerfindlichen Gründen blockt die Firewall aber nach einiger Zeit die Anfragen auf Port 80 von WAN nach LAN.

Im Anhang seht ihr meine Anfragen auf das Port 80 von WAN1.

Kann mir jemand erklären, was ich hier falsch mache bzw. was dieses Verhalten auslöst.

Vielen Dank!



So wie es aussieht muss ich noch eine zusätzliche Regel (WAN) erstellen, die besagt, dass von WAN auf LAN (DebianWeb1) zugegriffen werden darf.

Wieso aber funktioniert es eine Zeit lang ohne diese Regel?

Ist das normal?

Immer Bildchen von deinen Regeln (Firewall/NAT) posten und nicht irgendwelche Text-Auszüge. Grundsätzlich braucht es immer eine Firewallregel, NAT-Regeln können aber auf "Durchzug" gestellt werden, dann ist eine eigene Firewallregel obsolet, solltest Du aber als Anfänger nicht machen.

Wenn Du Änderungen vornimmst, werden ältere Verbindungen nicht automatisch gelöscht, das könnte erklären, was Du meinst, erlebt zu haben.

Was noch viel besser hilft als Screenshots ist ein Copy Paste von:

/ui/diagnostics/firewall/statistics#rules
- filter rules
- nat rules

Das einfach in einen Code block.


Code
Hardware:
DEC740

Hallo und danke schon mal für die Antworten.

Meine Config:

filter rules

    @0 scrub on em1 all fragment reassemble
    @1 scrub on em0 all fragment reassemble
    @2 scrub on em2 all fragment reassemble
    @0 block drop in log on ! em0 inet from 88.99.167.64/26 to any
    @1 block drop in log on ! em2 inet from 88.99.167.64/26 to any
    @2 block drop in log on ! em1 inet from 192.168.1.0/24 to any
    @3 block drop in log inet from 192.168.1.1 to any
    @4 block drop in log inet from 88.99.167.82 to any
    @5 block drop in log inet from 88.99.167.87 to any
    @6 block drop in log on em1 inet6 from fe80::be24:11ff:fe9e:bc38 to any
    @7 block drop in log inet all label "02f4bab031b57d1e30553ce08e0ec131"
    @8 block drop in log inet6 all label "02f4bab031b57d1e30553ce08e0ec131"
    @9 pass in log quick inet6 proto ipv6-icmp all icmp6-type unreach keep state label "1d245529367b2e34eeaff16086aeafe9"
    @10 pass in log quick inet6 proto ipv6-icmp all icmp6-type toobig keep state label "1d245529367b2e34eeaff16086aeafe9"
    @11 pass in log quick inet6 proto ipv6-icmp all icmp6-type neighbrsol keep state label "1d245529367b2e34eeaff16086aeafe9"
    @12 pass in log quick inet6 proto ipv6-icmp all icmp6-type neighbradv keep state label "1d245529367b2e34eeaff16086aeafe9"
    @13 pass out log quick inet6 proto ipv6-icmp from (self:3) to fe80::/10 icmp6-type echoreq keep state label "acdbb900b50d8fb4ae21ddfdc609ecf8"
    @14 pass out log quick inet6 proto ipv6-icmp from (self:3) to ff02::/16 icmp6-type echoreq keep state label "acdbb900b50d8fb4ae21ddfdc609ecf8"
    @15 pass out log quick inet6 proto ipv6-icmp from (self:3) to fe80::/10 icmp6-type echorep keep state label "acdbb900b50d8fb4ae21ddfdc609ecf8"
    @16 pass out log quick inet6 proto ipv6-icmp from (self:3) to ff02::/16 icmp6-type echorep keep state label "acdbb900b50d8fb4ae21ddfdc609ecf8"
    @17 pass out log quick inet6 proto ipv6-icmp from (self:3) to fe80::/10 icmp6-type routersol keep state label "acdbb900b50d8fb4ae21ddfdc609ecf8"
    @18 pass out log quick inet6 proto ipv6-icmp from (self:3) to ff02::/16 icmp6-type routersol keep state label "acdbb900b50d8fb4ae21ddfdc609ecf8"
    @19 pass out log quick inet6 proto ipv6-icmp from (self:3) to fe80::/10 icmp6-type routeradv keep state label "acdbb900b50d8fb4ae21ddfdc609ecf8"
    @20 pass out log quick inet6 proto ipv6-icmp from (self:3) to ff02::/16 icmp6-type routeradv keep state label "acdbb900b50d8fb4ae21ddfdc609ecf8"
    @21 pass out log quick inet6 proto ipv6-icmp from (self:3) to fe80::/10 icmp6-type neighbrsol keep state label "acdbb900b50d8fb4ae21ddfdc609ecf8"
    @22 pass out log quick inet6 proto ipv6-icmp from (self:3) to ff02::/16 icmp6-type neighbrsol keep state label "acdbb900b50d8fb4ae21ddfdc609ecf8"
    @23 pass out log quick inet6 proto ipv6-icmp from (self:3) to fe80::/10 icmp6-type neighbradv keep state label "acdbb900b50d8fb4ae21ddfdc609ecf8"
    @24 pass out log quick inet6 proto ipv6-icmp from (self:3) to ff02::/16 icmp6-type neighbradv keep state label "acdbb900b50d8fb4ae21ddfdc609ecf8"
    @25 pass in log quick inet6 proto ipv6-icmp from fe80::/10 to fe80::/10 icmp6-type echoreq keep state label "42e9d787749713a849d8e92432efdfaa"
    @26 pass in log quick inet6 proto ipv6-icmp from fe80::/10 to ff02::/16 icmp6-type echoreq keep state label "42e9d787749713a849d8e92432efdfaa"
    @27 pass in log quick inet6 proto ipv6-icmp from fe80::/10 to fe80::/10 icmp6-type routersol keep state label "42e9d787749713a849d8e92432efdfaa"
    @28 pass in log quick inet6 proto ipv6-icmp from fe80::/10 to ff02::/16 icmp6-type routersol keep state label "42e9d787749713a849d8e92432efdfaa"
    @29 pass in log quick inet6 proto ipv6-icmp from fe80::/10 to fe80::/10 icmp6-type routeradv keep state label "42e9d787749713a849d8e92432efdfaa"
    @30 pass in log quick inet6 proto ipv6-icmp from fe80::/10 to ff02::/16 icmp6-type routeradv keep state label "42e9d787749713a849d8e92432efdfaa"
    @31 pass in log quick inet6 proto ipv6-icmp from fe80::/10 to fe80::/10 icmp6-type neighbrsol keep state label "42e9d787749713a849d8e92432efdfaa"
    @32 pass in log quick inet6 proto ipv6-icmp from fe80::/10 to ff02::/16 icmp6-type neighbrsol keep state label "42e9d787749713a849d8e92432efdfaa"
    @33 pass in log quick inet6 proto ipv6-icmp from fe80::/10 to fe80::/10 icmp6-type neighbradv keep state label "42e9d787749713a849d8e92432efdfaa"
    @34 pass in log quick inet6 proto ipv6-icmp from fe80::/10 to ff02::/16 icmp6-type neighbradv keep state label "42e9d787749713a849d8e92432efdfaa"
    @35 pass in log quick inet6 proto ipv6-icmp from ff02::/16 to fe80::/10 icmp6-type echoreq keep state label "8752fca75c6be992847ea984161bd3f1"
    @36 pass in log quick inet6 proto ipv6-icmp from ff02::/16 to fe80::/10 icmp6-type routersol keep state label "8752fca75c6be992847ea984161bd3f1"
    @37 pass in log quick inet6 proto ipv6-icmp from ff02::/16 to fe80::/10 icmp6-type routeradv keep state label "8752fca75c6be992847ea984161bd3f1"
    @38 pass in log quick inet6 proto ipv6-icmp from ff02::/16 to fe80::/10 icmp6-type neighbrsol keep state label "8752fca75c6be992847ea984161bd3f1"
    @39 pass in log quick inet6 proto ipv6-icmp from ff02::/16 to fe80::/10 icmp6-type neighbradv keep state label "8752fca75c6be992847ea984161bd3f1"
    @40 pass in log quick inet6 proto ipv6-icmp from :: to ff02::/16 icmp6-type echoreq keep state label "71dd196398b3f1da265dbd9dcad00e70"
    @41 pass in log quick inet6 proto ipv6-icmp from :: to ff02::/16 icmp6-type routersol keep state label "71dd196398b3f1da265dbd9dcad00e70"
    @42 pass in log quick inet6 proto ipv6-icmp from :: to ff02::/16 icmp6-type routeradv keep state label "71dd196398b3f1da265dbd9dcad00e70"
    @43 pass in log quick inet6 proto ipv6-icmp from :: to ff02::/16 icmp6-type neighbrsol keep state label "71dd196398b3f1da265dbd9dcad00e70"
    @44 pass in log quick inet6 proto ipv6-icmp from :: to ff02::/16 icmp6-type neighbradv keep state label "71dd196398b3f1da265dbd9dcad00e70"
    @45 block drop in log quick inet proto tcp from any port = 0 to any label "7b5bdc64d7ae74be1932f6764a591da5"
    @46 block drop in log quick inet proto udp from any port = 0 to any label "7b5bdc64d7ae74be1932f6764a591da5"
    @47 block drop in log quick inet6 proto tcp from any port = 0 to any label "7b5bdc64d7ae74be1932f6764a591da5"
    @48 block drop in log quick inet6 proto udp from any port = 0 to any label "7b5bdc64d7ae74be1932f6764a591da5"
    @49 block drop in log quick inet proto tcp from any to any port = 0 label "ae69f581dc429e3484a65f8ecd63baa5"
    @50 block drop in log quick inet proto udp from any to any port = 0 label "ae69f581dc429e3484a65f8ecd63baa5"
    @51 block drop in log quick inet6 proto tcp from any to any port = 0 label "ae69f581dc429e3484a65f8ecd63baa5"
    @52 block drop in log quick inet6 proto udp from any to any port = 0 label "ae69f581dc429e3484a65f8ecd63baa5"
    @53 pass log quick inet6 proto carp from any to ff02::12 keep state label "cf439d72ef4d245e8ad4a1405df1f665"
    @54 pass log quick inet proto carp from any to 224.0.0.18 keep state label "2ffa978d51f7b3fbc9000c2895106ee7"
    @55 block drop in log quick proto tcp from <sshlockout:0> to (self:7) port = ssh label "669143f420c3ab4118bcb0bf4b5fd823"
    @56 block drop in log quick proto tcp from <sshlockout:0> to (self:7) port = 4430 label "42467dc18cdc1110c585b3707c67c408"
    @57 block drop in log quick from <virusprot:0> to any label "8e367e2f9944d93137ae56d788c5d5e1"
    @58 pass in log quick on em1 inet proto udp from any port = bootpc to 255.255.255.255 port = bootps keep state label "5168be2cca1e130b1ef2ac18161356a8"
    @59 pass in log quick on em1 proto udp from any port = bootpc to (self:7) port = bootps keep state label "0b032d1bab91fc97e4a7faf03a7f17c3"
    @60 pass out log quick on em1 proto udp from (self:7) port = bootps to any port = bootpc keep state label "5039e43005a9aa50eb032af274cc9aad"
    @61 pass in log quick on em1 inet6 proto udp from fe80::/10 to fe80::/10 port = dhcpv6-client keep state label "fef3d333d96a8d3558956de1fffc61cc"
    @62 pass in log quick on em1 inet6 proto udp from fe80::/10 to ff02::/16 port = dhcpv6-client keep state label "fef3d333d96a8d3558956de1fffc61cc"
    @63 pass in log quick on em1 inet6 proto udp from fe80::/10 to ff02::/16 port = dhcpv6-server keep state label "d2bd536587a9f5680c1f850b2d346839"
    @64 pass in log quick on em1 inet6 proto udp from ff02::/16 to fe80::/10 port = dhcpv6-server keep state label "3420206ced96c01ef73fbc4ac9deb745"
    @65 pass in log quick on em1 inet6 proto udp from fe80::/10 to (self:3) port = dhcpv6-client keep state label "0fd202708c326aebbe44ab710b6d3652"
    @66 pass out log quick on em1 inet6 proto udp from (self:3) port = dhcpv6-server to fe80::/10 keep state label "83f6c28de8efae9b444094e4a5bf898c"
    @67 block drop in log quick on em0 inet from <bogons:10> to any label "b7cd97a164650b538506fb551a0369e7"
    @68 block drop in log quick on em0 inet6 from <bogonsv6:76> to any label "f140a48ddade668b9d6f5259669a1d5c"
    @69 block drop in log quick on em0 inet from 10.0.0.0/8 to any label "1eb94a38e58994641aff378c21d5984f"
    @70 block drop in log quick on em0 inet from 127.0.0.0/8 to any label "1eb94a38e58994641aff378c21d5984f"
    @71 block drop in log quick on em0 inet from 100.64.0.0/10 to any label "1eb94a38e58994641aff378c21d5984f"
    @72 block drop in log quick on em0 inet from 172.16.0.0/12 to any label "1eb94a38e58994641aff378c21d5984f"
    @73 block drop in log quick on em0 inet from 192.168.0.0/16 to any label "1eb94a38e58994641aff378c21d5984f"
    @74 block drop in log quick on em0 inet6 from fc00::/7 to any label "45afd72424c84d011c07957569151480"
    @75 block drop in log quick on em2 inet from <bogons:10> to any label "cfca9bf047b2f647802e1a5817015864"
    @76 block drop in log quick on em2 inet6 from <bogonsv6:76> to any label "24183c6536bd5d0a49befdacee1df371"
    @77 block drop in log quick on em2 inet from 10.0.0.0/8 to any label "8c58f3cda89e2627c8512cdd8311f8c7"
    @78 block drop in log quick on em2 inet from 127.0.0.0/8 to any label "8c58f3cda89e2627c8512cdd8311f8c7"
    @79 block drop in log quick on em2 inet from 100.64.0.0/10 to any label "8c58f3cda89e2627c8512cdd8311f8c7"
    @80 block drop in log quick on em2 inet from 172.16.0.0/12 to any label "8c58f3cda89e2627c8512cdd8311f8c7"
    @81 block drop in log quick on em2 inet from 192.168.0.0/16 to any label "8c58f3cda89e2627c8512cdd8311f8c7"
    @82 block drop in log quick on em2 inet6 from fc00::/7 to any label "d31b1ae4c164311eef1886194b05b251"
    @83 pass in quick on lo0 all no state label "7535c94082e72e2207679aadb26afd92"
    @84 pass out log all flags S/SA keep state allow-opts label "fae559338f65e11c53669fc3642c93c2"
    @85 pass in log quick on em1 proto tcp from any to (self:7) port = http flags S/SA keep state label "41c1947b97324ba8139de1cb49fb9e93"
    @86 pass in log quick on em1 proto tcp from any to (self:7) port = 4430 flags S/SA keep state label "41c1947b97324ba8139de1cb49fb9e93"
    @87 pass out log route-to (em0 88.99.167.65) inet from (em0:1) to ! (em0:network:1) flags S/SA keep state allow-opts label "0aec9733af953ca831fab85fec6280a0"
    @88 pass in log quick on em0 reply-to (em0 88.99.167.65) inet proto tcp from 176.66.68.203 to (self:4) port 1:4430 flags S/SA keep state label "a6fd83aea979715adab770f92cc8e217"
    @89 pass in log quick on em0 reply-to (em0 88.99.167.65) inet proto tcp from any to <DebianWeb1:1> port = http flags S/SA keep state label "734917857cf01c74773f5afeb600c35c"
    @90 pass in quick on em1 inet from (em1:network:1) to any flags S/SA keep state label "da3b38affa7b85c1fc3035bfc013c94f"
    @91 pass in quick on em1 inet6 from (em1:network:*) to any flags S/SA keep state label "bfd9919a7d81b261ec898404dd73cf21"
    @92 pass in quick on em1 inet6 from fe80::/10 to any flags S/SA keep state label "bfd9919a7d81b261ec898404dd73cf21"
    @93 pass in quick on em2 inet proto tcp from any to <DebianWeb2:1> port = http flags S/SA keep state label "4d73f4b3dc606caba4268ee0d8632546"

nat rules

    @0 no nat proto carp all
    @1 nat on em0 inet from (em1:network:1) to any port = isakmp -> (em0:0) static-port
    @2 nat on em0 inet from (lo0:network:1) to any port = isakmp -> (em0:0) static-port
    @3 nat on em0 inet from (em2:network:1) to any port = isakmp -> (em0:0) static-port
    @4 nat on em0 inet from 127.0.0.0/8 to any port = isakmp -> (em0:0) static-port
    @5 nat on em0 inet from (em1:network:1) to any -> (em0:0) port 1024:65535
    @6 nat on em0 inet from (lo0:network:1) to any -> (em0:0) port 1024:65535
    @7 nat on em0 inet from (em2:network:1) to any -> (em0:0) port 1024:65535
    @8 nat on em0 inet from 127.0.0.0/8 to any -> (em0:0) port 1024:65535
    @0 no rdr proto carp all
    @1 no rdr on em1 proto tcp from any to (em1:2) port = http
    @2 no rdr on em1 proto tcp from any to (em1:2) port = 4430
    @3 rdr log on em0 inet proto tcp from any to <WAN1:1> port = http -&gt; &lt;DebianWeb1&gt; port 80 round-robin
    @4 rdr log on em2 inet proto tcp from any to <WAN2:1> port = http -&gt; &lt;DebianWeb2&gt; port 80 round-robin


Meinst du das so?

December 29, 2023, 02:38:13 PM #5 Last Edit: December 29, 2023, 02:40:34 PM by mcdaniels
Quote from: Bob.Dig on December 29, 2023, 11:21:04 AM
Immer Bildchen von deinen Regeln (Firewall/NAT) posten und nicht irgendwelche Text-Auszüge.

Bilder anbei.

DebianWeb1 192.168.1.5 (LAN)
DebianWeb2 192.168.1.15 (LAN)

WAN zu DebianWeb1 funktioniert.
WAN2 zu DebianWeb2 funktioniert nicht.

Opnsense Webport hab ich auf 4430 verlegt.

leider muss ich noch etwas anhängen.

Wenn man sich das Logging anschaut (Anhang) sieht man dass eine Anfrage von mir 176.66.68.203 auf die 88.99.167.82:80 (WAN) in 3 "Logzeilen" abgearbeitet ist und funktioniert.

Wenn man dann auf das WAN2 Logging schaut startet das mit der Anfrage von mir (80) auf 88.99.167.87:80.
Dann macht er da via LAN etwas von LAN nach WAN (meine WAN IP)
Dann kommt nochmals eine Anfrage von meiner WAN IP ans WAN2 Port rein
und letztlich wieder von LAN an meine WAN IP

irgendetwas stimmt  da wohl nicht.

Wie sind denn diese WANs konfiguriert? Und zeige mal das komplette Outbound NAT.


December 29, 2023, 04:18:07 PM #9 Last Edit: December 29, 2023, 04:28:02 PM by mcdaniels
WAN1 und WAN2 anbei

Was ich noch dazu sagen muss ist dass das alles auf/in einer VM läuft (Proxmox). Hierbei ist WAN1 & WAN2 in einem Bridgedsetup beide verwenden den gleichen GW. (Sofern das relevant ist).

Die Opnsense hat insgesamt 3 Interfaces zugeordnet. Ein Interface ist die LAN-Zone (ohne phys Nic Verbindung)

Die zwei verbleibenden Interfaces  (em2 = WAN2 und em0 = WAN1) sind dann an die virtuelle Netzwerkbrücke (vmbr0) angeschlossen und werden eben über dieses Bridge-Setup angesprochen. (Beide haben eine separate MAC-Adresse).

Die Haupt IP dieses Servers auf die die anderen -oben erwähnten Interfaces- gebridged sind und über die nur der Proxmox ansprechbar ist sieht so aus von der Konfiguration.
auto vmbr0
iface vmbr0 inet static
        address 88.99.167.121/26
        gateway 88.99.167.65
        bridge-ports enp0s31f6
        bridge-stp off
        bridge-fd 0
        bridge_maxwait 0

Die OPNSense spreche ich aber mit der IP 88.99.167.82 an (eben der zugeordneten WAN IP)

Ich wollte damit nur verdeutlichen, um welches Setup es sich hier (drumherum) handelt.

December 29, 2023, 04:34:42 PM #10 Last Edit: December 29, 2023, 04:36:34 PM by Bob.Dig
Anhand des Outbound NAT kannst Du schon sehen, dass deine WANs nicht gleich behandelt werden. WAN2 hat anscheinend gar kein Outbound NAT, das ist schlecht.

Da deine config aber mehrere öffentliche IP-Adressen auf dem selben Interface beinhaltet, bin ich hier raus, weil kein Wissen dazu. 

Hallo,könnte man dem WAN2 kein outbound Nat zuordnen?

Schade dass du raus bist.

Du hast also zwei WAN-IPs im selben Netzwerk? Du sagst, dass beide Adressen dasselbe Gateway haben, also sind sie im selben Netz.

Damit ist klar, warum das nicht wirklich geht. Hast Du das Multi-WAN nach Anleitung eingerichtet? Wirklich ganz genau? Mit zwei verschiedenen Monitor-Adressen? Und auch die VErteilungsregeln erstellt?

Per STandard schiebt er nämlich ein Paket auf dem Interface raus, as gerade passt....zumindest wenn man keine besonderen Regeln eingerichtet hat.
Das könnte das VErhalten erklären.
Aaaber: zwei Interfaces im selben Netz macht nicht wirklich Sinn und bringt meist mehr Probleme, als es löst.

/KNEBB

Hallo,

ist das Problem noch offen?

1. Ich würde mit einem WAN-Interface statisch. anfangen.
2. Dann das eingehende und das ausgehende NAT
3. Danach mit nur dem 2. WAN-Interface den gleichen Test
4. Im Anschluß gewuchtetes Multi-WAN

(Zwei L3-Interfaces im selben Netz ist in jedem Fall falsch, da kein eindeutiges Routing möglich ist. Wichtig ist zudem, asyncrones Routing zu vermeiden.)

Morris
Morris Görke
iternas GmbH
https://www.iternas.com/opnsense