Elektrine lite

← Feed

@emotional_soup_88__dup_21417@programming.dev

Post #508167

2026-03-03 18:10 UTC

If I may ask a follow up question, just out of curiosity, I did an ip a on my phone that is connected to the same router as the system whose firewal I was referring to in my original post and it gave me: inet 192.168.1.214/24 brd 192.168.1.255 scope global wlan0 Which to my untrained eye indicates that my phones WiFi interface has been alotted the .214 address in the /24 space/subnet. But if I understand you correctly, this has to do with the above being routing related - how my phone reaches WAN -, while my original post was about firewalling. And when it comes to firewalling, you specify a host with a mask of /32?

Replies (2)

  • @jrgd@lemmy.zip 2026-03-03 18:49

    Iproute2 definitely does write things a bit compact. ip address show and shorthands state the routed local address space (192.168.1.x/24) and the actual /32 address (192.168.1.214) you are assigned as one unit. Additionally, it shows the broadcast address for the space. Ironically, ip route show may genuinely give you less confusing information, clearly splitting the actual route and showing your straight IPv4 address as src. Typically in firewalling, you’d use /32 to allow a singular IPv4 host. This is analogous to using /128 for IPv6 hosts. You can absolutely use /24, /16, /8, or any other mask really if you need to target a range of IP addresses for a rule to apply to. Technically, /32 is a range itself, just with a size of 1. There are CIDR calculators available to play around and see what different CIDR masks actually target.

    Open ##508193

  • @CosmicGiraffe@lemmy.world 2026-03-03 19:07

    You might want to use either a /24 address or a /32 address in a firewall rule, depending on what you’re trying to do. The difference is that the /24 one refers to a set of IPs, while the /32 one applies to only one IP. Say you’re adding a firewall rule like iptables -A - s 192.168.1.123/32 - j ACCEPT. This will accept all traffic with the source IP 192.168.1.123. If instead you use iptables -A - s 192.168.1.123/24 - j ACCEPT, you’ll accept all traffic with a source IP in the 192.168.1.123/24 subnet, which is all the IPs between 192.168.1.0 & 192.168.1.255. In the case of your WiFi IP, the subnet does something different. It tells you which IP addresses you should expect to be able to contact directly, and which you need to contact via a router. 192.168.1.214/24 says that all the IPs between 192.168.1.0 & 192.168.1.255 can be reached directly, whereas IPs outside that range need to be sent to a router. ip route will show you the routes a device knows about. It’ll look something like this (simplifying a bit): default via 192.168.1.1 192.168.1.0/24 dev wlan0 src 192.168.1.214 The first line is the default route, which is used when no more specific route exists. It says that you talk to these IPs by sending your traffic to 192.168.1.1 (your wifi router) and it’ll send it on from there. The second one says that for IPs in the 192.168.1.0/24, you directly talk to them using your wlan0 interface

    Open ##508214