Gentoo Archives: gentoo-user

From: Laurence Perkins <lperkins@×××××××.net>
To: "gentoo-user@l.g.o" <gentoo-user@l.g.o>
Subject: RE: [gentoo-user] MAC whitelisting and UDP traffic.
Date: Thu, 14 Jul 2022 23:02:54
Message-Id: MW2PR07MB4058A6E2BB8050B567682FA2D2889@MW2PR07MB4058.namprd07.prod.outlook.com
In Reply to: Re: [gentoo-user] MAC whitelisting and UDP traffic. by Adam Carter
1 >>
2 >> From: Adam Carter adamcarter3@×××××.com<mailto:adamcarter3@×××××.com>
3 >> Sent: Tuesday, July 12, 2022 11:13 PM
4 >> To: Gentoo User gentoo-user@l.g.o<mailto:gentoo-user@l.g.o>
5 >> Subject: Re: [gentoo-user] MAC whitelisting and UDP traffic.
6 >>
7 >>
8 >> On Tue, Jul 12, 2022 at 7:35 AM Laurence Perkins lperkins@×××××××.net<mailto:lperkins@×××××××.net> wrote:
9 >> Ok, I asked a while ago about whitelisting MAC ranges for firewall rules, and just so you know, adding 16 million potential MAC addresses to the firewall… Doesn’t work well… No matter how you do it. So I had to write a daemon to monitor which ones were local and add just those. Whatever.
10 >>
11 >> That brings me to the next problem. The routing and NAT work just fine if I’m letting everything through. But if I’m dropping connections that don’t come from authorized devices then UDP only works in the outbound direction… TCP is fine.
12 >>
13 >> For reference, the rules consist of:
14 >>
15 >> iptables -t nat -I POSTROUTING -o <OUTSIDE> -j MASQUERADE
16 >> iptables -A FORWARD -i <OUTSIDE> -o <INSIDE> -m state --state RELATED,ESTABLISHED -j ACCEPT
17 >>
18 >> And then the daemon adds a:
19 >> iptables -A FORWARD -i <INSIDE> -o <OUTSIDE> -m mac --mac-source <MAC ADDRESS> -j ACCEPT
20 >>
21 >> for each authorized device.
22 >>
23 >> TCP works perfectly.
24 >> UDP based protocols send out just fine, but any replies get blocked if the FORWARD chain’s default policy is DROP.
25 >>
26 >> Now… Everything I’m reading says that it’s supposed to be able to associate UDP replies based on port number, which indeed it must be doing in order for them to get translated correctly and directed to the correct device inside the NAT when the default policy is ACCEPT.
27 >>
28 >> So why is that rule to accept related packets not triggering for them?
29 >
30 > I also would have expected the UDP replies to be permitted via -state RELATED,ESTABLISHED.
31 >
32 > Do they at least get into the state table;
33 > grep udp /proc/net/nf_conntrack
34 >
35
36 Well, they had been all getting in that list for the outbound packets, but then never noting that replies had come...
37
38 This morning when I went to pull a few lines for this reply, they're there and marked as ASSURED.
39
40 And yet, of the four devices attached to the inside for testing purposes, only one of them has established its OpenVPN connection.
41
42 So I'm going to set up some more detailed tests and some additional hardware arrangements and see if I can get more specific about what does and does not connect properly.
43
44 LMP