this post was submitted on 03 Mar 2026
33 points (97.1% liked)
Linux
63475 readers
911 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 6 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
If I may ask a follow up question, just out of curiosity, I did an
ip aon 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 wlan0Which to my untrained eye indicates that my phones WiFi interface has been alotted the.214address in the/24space/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?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 useiptables -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 routewill show you the routes a device knows about. It'll look something like this (simplifying a bit):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
Thank you very much! :)
Interesting why
iptablesbehaves like that though. Because, if I understand it correctly, specifying any address between 192.168.1.[0...255]/24 will result in all addresses in that range to be accepted? So, the only way to actually single out one host is to use the mask /32...?Yes, exactly. The convention is to use the lowest address in the range (e.g. 192.168.1.0/24), since you're allowing a range of addresses rather than a single one.
The reason to do this is that many firewall rules will be based on sets of addresses - you might want to allow traffic from any device in your local network without having to add individual rules for each
Tomorrow, at work, I'm gonna brag about what I have learned here today, until my colleagues' ears fall off.
Thanks again! :)
Iproute2 definitely does write things a bit compact.
ip address showand 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 showmay genuinely give you less confusing information, clearly splitting the actual route and showing your straight IPv4 address assrc.Typically in firewalling, you'd use /32 to target 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.
Sweet! Thanks for another clear explanation! Have good rest of your day! :)