FreeBSD und CARP

asg

push it, don´t hype
Moin.

Ich muss irgendwo einen Denkfehler haben, komme aber nicht drauf:

Zwei primäre Firewalls (fw1 und fw2) welche mit dem WAN über einen Router verbunden sind. Hinter den Firewalls rennen zwei Applikationsserver (app1 und app2), ebenfalls mit PF, einer der beiden ist das GW für die Clients im internen Netz.

Es hier um fw1 und fw2 die als transparente FW mit PF+CARP+PFSYNC unter FBSD 6.1 arbeiten sollen.

Das GW für die internen Clients ist app2 (10.4.1.251), und das GW für app2 ist wiederum .252/29 (das eine CARP interface auf fw1 und fw2). app2 hat auch eine externe Adresse, .251/29 und ist via einer anderen NIC mit dem internen Netz verbunden:10.4.1.251

Das läuft alles. Regeln passen, alles geht.

fw1 (zwei externe Adressen wobei int zu app geht)
ext -> .242/29
int -> .249/29

fw2 (zwei externe Adressen wobei int zu app geht)
ext -> .243/29
int -> .250/29

auf beiden fw habe ich:
CARP0 -> .252/29
CARP1 -> .244/29

fw1 der Master (etc/rc.conf):
Code:
cloned_interfaces="carp0 carp1"
network_interfaces="lo0 xl0 xl1 xl2 carp0 carp1 pfsync0 pflog0"
ifconfig_carp0="vhid 1 pass foo xxx.xxx.xxx.244 255.255.255.248"
ifconfig_carp1="vhid 2 pass bar xxx.xxx.xxx.252 255.255.255.248"
pfsync_enable="YES"
pfsync_syncdev="xl2"

fw2 der Backups (etc/rc.conf):
Code:
cloned_interfaces="carp0 carp1"
network_interfaces="lo0 xl0 xl1 xl2 carp0 carp1 pfsync0 pflog0"
ifconfig_carp0="vhid 1 pass foo advskew 128 xxx.xxx.xxx.244
255.255.255.248"
ifconfig_carp1="vhid 2 pass bar advskew 128 xxx.xxx.xxx.252
255.255.255.248"
pfsync_enable="YES"
pfsync_syncdev="xl2"

Auf beiden fw /etc/sysctl.conf:
Code:
net.inet.carp.preempt=1
net.inet.carp.allow=1
net.inet.carp.log=1

In beiden pf.conf:
Code:
pass out on $ext_if proto carp keep state
pass out on $int_if proto carp keep state
pass quick on { xl2 } proto pfsync
pass on { xl0 xl1 } proto carp keep state

xl0 das externe interface, xl1 das interne und xl2 ist mittels crossover kabel mit fw1 und fw2 verbunden.

Wenn ich nun CARP0 runternehme:
ifconfig carp0 down

Bekomme ich folgenden output bei ifconfig

fw1:
Code:
carp0: flags=8<LOOPBACK> mtu 1500
        inet xxx.xxx.xxx.244 netmask 0xffffff00 
        carp: INIT vhid 1 advbase 1 advskew 0
carp1: flags=49<UP,LOOPBACK,RUNNING> mtu 1500
        inet xxx.xxx.xxx.252 netmask 0xffffff00 
        carp: MASTER vhid 2 advbase 1 advskew 0

fw2:
Code:
carp0: flags=49<UP,LOOPBACK,RUNNING> mtu 1500
        inet xxx.xxx.xxx.244 netmask 0xffffff00 
        carp: MASTER vhid 1 advbase 1 advskew 128
carp1: flags=49<UP,LOOPBACK,RUNNING> mtu 1500
        inet xxx.xxx.xxx.252 netmask 0xffffff00 
        carp: BACKUP vhid 2 advbase 1 advskew 128

So, fw arbeitet nun als MASTER, aber nur auf CARP0. Ich dachte wenn preempt aktiviwert ist, das dann alle CARP interfaces übernommen werden.

Bevor ich nun CARP0 runternehme führe ich einen ping aus von intern nach extern. Nehme ich CARP0 runter, bricht der Ping nicht ab. Gut.
ABER, ssh, http, ftp, alles andere, bricht ab.
Einfache Frage: Warum? Was zum Henker übersehe ich gerade?
 
Hallo asg,

gibt es ein log-file (net.inet.carp.log=1)? Ich kann es dann mal unserem Sysadmin zeigen (am Montag).

Viele Grüße

Jürgen
 
Hmpf. Langsam macht es mich kirre.
Auf fw1:
Code:
#netstat -ssp carp
carp:
        82 packets received (IPv4)
                46 discarded for bad vhid
        4247 packets sent (IPv4)

#netstat -p carp -s
carp:
        82 packets received (IPv4)
        0 packets received (IPv6)
                0 packets discarded for wrong TTL
                0 packets shorter than header
                0 discarded for bad checksums
                0 discarded packets with a bad version
                0 discarded because packet too short
                0 discarded for bad authentication
                46 discarded for bad vhid
                0 discarded because of a bad address list
        4265 packets sent (IPv4)
        0 packets sent (IPv6)
                0 send failed due to mbuf memory error

Code:
#tcpdump -n -e -ttt -i pflog0
000724 rule 14/0(match): pass out on xl2: 192.168.1.10 > 224.0.0.240:  pfsync 532
661629 rule 14/0(match): pass out on xl2: 192.168.1.10 > 224.0.0.240:  pfsync 180
000025 rule 14/0(match): pass out on xl2: 192.168.1.10 > 224.0.0.240:  pfsync 100
000009 rule 14/0(match): pass out on xl2: 192.168.1.10 > 224.0.0.240:  pfsync 100
000017 rule 14/0(match): pass out on xl2: 192.168.1.10 > 224.0.0.240:  pfsync 100
303007 rule 14/0(match): pass out on xl2: 192.168.1.10 > 224.0.0.240:  pfsync 52
039397 rule 14/0(match): pass in on xl2: 192.168.1.11 > 224.0.0.240:  pfsync 180
964851 rule 14/0(match): pass out on xl2: 192.168.1.10 > 224.0.0.240:  pfsync 268
041004 rule 14/0(match): pass in on xl2: 192.168.1.11 > 224.0.0.240:  pfsync 268
000204 rule 14/0(match): pass out on xl2: 192.168.1.10 > 224.0.0.240:  pfsync 180
000011 rule 14/0(match): pass out on xl2: 192.168.1.10 > 192.168.1.11:  pfsync 20

Code:
#tcpdump -i xl2 
12:58:55.809260 IP fw0.internp.xxx.de > 224.0.0.240:  pfsync 228
12:58:56.362053 IP fw0.internp.xxx.de > 224.0.0.240:  pfsync 268
12:58:56.363494 IP fw0.internp.xxx.de > 224.0.0.240:  pfsync 356
12:58:56.363509 IP fw0.internp.xxx.de > fw1.internp.xxx.de:  pfsync 20
12:58:56.364026 IP fw1.internp.xxx.de > 224.0.0.240:  pfsync 92

Auf fw1:
Code:
#netstat -ssp carp
carp:
        592 packets received (IPv4)
        4 packets sent (IPv4)
#netstat -p carp -s
carp:
        606 packets received (IPv4)
        0 packets received (IPv6)
                0 packets discarded for wrong TTL
                0 packets shorter than header
                0 discarded for bad checksums
                0 discarded packets with a bad version
                0 discarded because packet too short
                0 discarded for bad authentication
                0 discarded for bad vhid
                0 discarded because of a bad address list
        4 packets sent (IPv4)
        0 packets sent (IPv6)
                0 send failed due to mbuf memory error

Code:
154727 rule 12/0(match): pass in on xl2: 192.168.1.10 > 224.0.0.240:  pfsync 356
013760 rule 12/0(match): pass out on xl2: 192.168.1.11 > 224.0.0.240:  pfsync 268
001926 rule 12/0(match): pass in on xl2: 192.168.1.10 > 224.0.0.240:  pfsync 452
087836 rule 12/0(match): pass in on xl2: 192.168.1.10 > 224.0.0.240:  pfsync 532
125595 rule 12/0(match): pass in on xl2: 192.168.1.10 > 224.0.0.240:  pfsync 532
022077 rule 12/0(match): pass in on xl2: 192.168.1.10 > 224.0.0.240:  pfsync 180

Code:
13:04:32.148775 IP sffwp0.internp.suedfactoring.de > 224.0.0.240:  pfsync 68
13:04:32.235424 IP sffwp1.internp.suedfactoring.de > 224.0.0.240:  pfsync 268
13:04:32.963952 IP sffwp1.internp.suedfactoring.de > 224.0.0.240:  pfsync 92
13:04:32.964947 IP sffwp1.internp.suedfactoring.de > 224.0.0.240:  pfsync 228

Ich stehe auf dem Schlauch.
Nehme ich carp0 auf fw1 runter, wird carp0 auf fw2 zum Master, und carp0 auf fw1 steht auf INIT. Ok, unterhalten die sich also.
Dennoch brechen alle Verbindungen weg.
Ein traceroute dauert ewig, wenn überhaupt.

Hmm, traceroute bei normalen Betrieb:
Code:
traceroute www.bsdforen.de
traceroute to www.bsdforen.de (212.204.60.79), 64 hops max, 40 byte packets
 1  10.4.1.251 (10.4.1.251)  0.398 ms  1.602 ms  0.787 ms
 2  port-212-xxx-xxx-249.static.qsc.de (212.xxx.xxx.249)  1.341 ms  1.241 ms  1.942 ms
 3  port-212-xxx-xxx-241.static.qsc.de (212.xxx.xxx.241)  2.022 ms  2.186 ms  2.974 ms
 4  bsn2.stg.qsc.de (213.148.133.111)  6.005 ms  22.403 ms  5.910 ms
[...]
Ok, geht also über mein GW 10.4.1.251, welches auf dem Client eingetragen ist, und dann über das interne Interface von fw1 zum router, ins Internet.

Nehme ich carp0 auf fw1 runter, dann sollte der Verkehr ja über fw2 gehen. Mach ich ein traceroute, kommt das:
Code:
traceroute www.bsdforen.de
traceroute to www.bsdforen.de (212.204.60.79), 64 hops max, 40 byte packets
 1  10.4.1.251 (10.4.1.251)  0.735 ms  2.494 ms  0.578 ms
 2  port-212-xxx-xxx-250.static.qsc.de (212.xxx.xxx.250)  2.000 ms  1.955 ms  1.969 ms
 3  * * *
 4  * * *
 5  core2.stg.qsc.de (87.234.9.129)  5.045 ms^C
[...]
Auch wieder über mein GW, diesmal aber geht der Weg über .250, dem internene interface von fw2.

Auf dem GW 10.4.1.251 ist als GW die 212.xxx.xxx.252, sprich CARP0 eingetragen.
 
Ne kleine schnelle Grafik
 

Anhänge

  • netz.webp
    netz.webp
    15,3 KB · Aufrufe: 373
Zurück
Oben