![]() |
|
OpenBSD Security Functionally paranoid! |
![]() |
|
Thread Tools | Display Modes |
|
|
|||
![]()
I still have a problem.
I had been sharing a network with my landlord, but for various reasons we needed to split it. I acquired another address and separated my network. The issue is that we bought together a printer, which remains on his (flat) network with IP addresses 192.168.0.1/24. My network currently looks like this: Code:
#---------------------------------# # Macros #---------------------------------# # Interfaces # Externa interface ext_if="igc0" # VLANs interfaces vlan_1="igc1" vlan_3="igc3" For that I have in /etc/rc.conf.local Code:
dhcp_flags=igc1 Code:
inet autoconf Code:
pass in on vlan_1:network to $vlan_3 Questions: 1 Is my approach to connect the two networks to reach the printer reasonable? 2. If so, what is my problem with not loading the rules, and how to solve it? Kindest regards, M |
|
|||
![]()
Hi jggimi,
yes, it is a typo, the /etc/rc.conf.local has the correct dhcpd_flags. Yes, I understand the treatment of the dynamically changing interface, in fact,I have such a rule for $ext_if. However, when I was experimenting with the $vlan_3 to ensure that routing worked I assigned it a fixed address, and then forgot about the rule. Typical moron(tm). Kindest regards, M |
|
|||
![]()
Hi jggimi,
thank you again for your additional advice. Obviously, I have some difficulty understanding the man-pages. From pf.conf man-page (emphasis supplied): Code:
:network Translates to the network(s) attached to the interface. In that regard, I have difficulty interpret the in and out directives. Again, from the pf.conf: Code:
in or out A packet always comes in on, or goes out through, one interface. in and out apply to incoming and outgoing packets; if neither are specified, the rule will match packets in both directions. It is a wonder that my rule set sort of works. Kindest regards, M |
|
||||
![]()
I interpret ":network" to mean "all the subnet addresses that can be reached via this NIC." If I have a NIC configured with the IPv4 address (and CIDR netmask) 198.51.100.20/24, then the IPv4 ":network" range would be that entire /24 subnet: the 256 addresses between 198.51.100.0 and 198.51.100.254 for devices, with .255 reserved for broadcast. Packets forwarded from other networks through to that NIC would be outside the :network range.
With PF, it helps to remember that "from" "to" "in" "out" and "on" just restrict what traffic will match the rule. A rule with "on" will only apply to traffic transiting the named NIC. The "in" and "out" options apply to traffic direction -- from the point of view of the system running PF. Rules that use ":network" will further restrict what traffic matches the rule, as it will only match traffic that originates from or terminates to devices with ":network" addresses, and won't match traffic forwarded to or from other networks, such as traffic flowing to and from the Internet. |
|
|||
![]()
Hi jggimi,
thank you for trying to help me understand, but the more I am working on the rules, the more I am convinced that it is just a pure luck that I am as far -by my admittedly low standards - as I am. As I am now struggling with routing between the LANs, by means of an example consider this rule: Code:
pass in on $lan_1 from $lan_1:network to $lan_2:network But, since the packet needs to go out, why not to write it as follows: Code:
pass out from $lan_1:network to $lan_2:network No wonder that I feel like taking a rope and go shoot myself into a lake. Kindest regards, M BTW, have a healthy and prosperous New Year, both in your personal and professional life. M |
|
||||
![]()
Let's look at both rules.
Quote:
Quote:
You can see which rules are applied to traffic with tcpdump(8) and pflog(4). The matching rule, pass or block, is reported by rule number. You can use pfctl(8) to translate the rule number to the rule with # pfctl -sr -R <number> .I try to avoid using "in", "out", and "on" unless they're truly necessary, because it's easy to confuse them, and they limit what traffic will match. |
|
|||
![]()
Hi jggimi,
your explanation Quote:
Code:
in or out A packet always comes in on, or goes out through, one interface. in and out apply to incoming and outgoing packets; if neither are specified, the rule will match packets in both directions. So, if "in and "out" refer to the PS system, then how to write a rule for routing between lan_1 and lan_2? Like this: Code:
pass from $lan_1:network to $lan_2:network Code:
pass on $vlan_1 from $lan_1:network to $lan_2:network Kindest regards. M |
|
||||
![]()
The "PF system" in my post above is a short form for "the operating system where PF is running."
When that operating system is acting as a network router, packets arrive at the system via one NIC, and are then forwarded for departure via a different NIC, usually. The "in" filter option limits the rule to arriving packets, while the "out" filter option limits rules to departing packets. If instead of using "in" "out" and "on" your rules were written with only "from" and "to", packet direction and NIC selection no longer limit possible matches. For example, consider this simple rule set. There's no NICs mentioned, and no packet direction. But, I do need to have subnet level "network" addresses known when crafting these rules: Quote:
|
|
|||
![]()
Hi jggimi,
thank you for your patience, it is now very clear to me what you meant by the limitation adding all the options, as well as the OS on which the PF is running. Without any disrespect meant, I do understand the keep state and/or matching rules. Hence I have them in my configuration: Code:
#---------------------------------# # VLAN 192.168.1.0/24 #---------------------------------# # Allow traffic to any member of VLAN to any other member and the Internet pass in on $vlan_1 # Block DNS queries not addressed to internal DNS server. block return in quick on $vlan_1 proto { udp tcp } to ! $vlan_1 port { 53 853 } # Allow connection to $vlan_2 pass from $vlan_1:network to $vlan_2:network # Allow data packets to pass from the router out through the NIC to the # computers or devices attached. pass out on $vlan_1 inet keep state # NAT pass out on $ext_if inet from $vlan_1:network to any nat-to ($ext_if) #---------------------------------# # VLAN 192.168.2.0/24 #---------------------------------# # Allow traffic to any member of VLAN to any other member and the Internet pass in on $vlan_2 # Block DNS queries not addressed to internal DNS server. block return in quick on $vlan_2 proto { udp tcp } to ! $vlan_2 port { 53 853 } # Allow connection to $vlan_1 pass from $vlan_2:network to $vlan_1:network # Allow data packets to pass from the router out through the NIC to the # computers or devices attached. pass out on $vlan_2 inet keep state # NAT pass out on $ext_if inet from $vlan_2:network to any nat-to ($ext_if) Kindest regards, M |
|
||||
![]()
At least that excerpt has rules and comments that are easy for me to read and to understand your intent.
![]() I went back through the PF User's Guide and found this reference to the various modifiers, located in the NAT section. It may be clearer than what's in pf.conf(5): Quote:
|
|
|||
![]()
Hi jggimi,
well, I always make copious notes to (i) clarify in my mind what I am trying to do and (ii) to remember what I did. I also looked at the documentation, as as I am interpreting it, a matching pass rule automatically creates keep state. Regardless, keep state or my two rules, I still cannot route. I spent another frustrating time on that, nothing that I tried or saw in other people's configuration seems to work for me. I have even learned about tcdump, but I do not quite understand its usefulness. For example, if I see that ping is not getting a response, what good is it to see the same information on tcdump? Kindest regards, M |
|
||||
![]()
Is the syctl `net.inet.ip.forwarding` truly set to 1? If it is, then I recommend starting with a very simple temporary configuration, perhaps default pass with nat-to, just to confirm the problem is in your pf.conf file.
Quote:
Code:
# enable for logging: #match log (matches) # tcpdump -nei pflog0 I'll see every matching pass or block, with rule number. Rule numbers can be converted to the filter rule text with # pfctl -sr -R <number> .
|
|
|||
![]()
Hi jggimi,
thank you for your continued help. Quote:
Tha nat-to is working, I can access the Internet from both VLANs. So, my lizard brain reasons that the routing is (partially) working. (They are not actual VLANs yet, I have the testing computers on different switches). I can ping every device on the VLANs network from the firewall, but not from any of the VLANs, which seems consistent with the inter-LAN routing failure.. Quote:
I do not know, how else to approach it, as I had been working on the inter-LAN routing for past three days, trying -out of desperation - every rule that people posted, (even yours or J65nko's, who also seems knowledgeable), but nothing seems to work. Kindest regards, M |
|
||||
![]()
You can limit the tcpdump output to traffic to or from a specific host.
Code:
# tcpdump -nei pflog0 host 192.168.9.9 Code:
# tcpdump -nei pflog0 src host 192.168.9.9 Code:
# tcpdump -nei pflog0 src host 192.0.2.5 and dst host 198.51.100.27 ![]() |
|
|||
![]()
Hi jggimi,
thank you very much for the tcpdump commands, I will see if I can find the problem. If not, I plan to comment all the specific blocking rules, e.g., RFC1918, no-route, urpf-failed, etc., with just Code:
block all If it does not help, well, it will be an indication that I am too stupid for setting the firewall/router. Kingest regards, M |
|
|||
![]()
Hi jggimi,
Quote:
If not, would it not be more efficient to forget about the tcpdump and proceed with the proposed elimination and re-insertion the blocking rules? Kindest regards, M |
|
||||
![]()
If you can, please show me some of the tcpdump output, including the rule that blocked, and the pass rule you expected to have pass, but which didn't match.
(You haven't posted the complete pf.conf, so I'm unsure if you've got an early "block quick" which accidentally interferes with the traffic you want to have pass in later rules.) |
![]() |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenBSD firewall/router with (so far) two minor issues | mefisto | OpenBSD Security | 3 | 29th December 2024 03:03 AM |
Hardware for embedded FreeBSD/OpenBSD custom router/firewall ( Ent. firewall, ADSL ro | Bsaidus | General Hardware | 5 | 24th November 2023 09:57 PM |
Smallest, cheapest hardware for OpenBSD router + firewall | beiroot | OpenBSD General | 22 | 12th April 2018 09:37 AM |
MacVTap VEPA with OpenBSD router/firewall, need bridge to reflect on same segment | rbigm101 | OpenBSD Security | 17 | 20th September 2016 04:03 PM |
OpenBSD amd64 or i386 for firewall/router | J65nko | OpenBSD General | 7 | 24th December 2009 09:06 PM |