Re: Possibly dangerous interpretation of address/prefix pair in -s option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/3/2022 11:23 AM, Stefan Riha wrote:
Hmm, but don't other programs do indeed interpret 10.0.0.2/24 differently? For example systemd-networkd interprets 10.0.0.2/24 as a single Ip address in the subnet 10.0.0.0/24. Which makes a lot of sense to me, because why would one specify the .2 at the end, if one meant the subnet?

I would say that it depends on context; that is, what the parameter is supposed to be. Is it meant to specify single address, a network, or either?

In the your systemd-networkd example, IIRC, that is supposed to be a single IP address, and `10.0.0.2/24` is a short hand for entering `10.0.0.2` and `255.255.255.0` for a network interface.

Another example that comes to mind where context matters, is the older `route` command (that predates `ip route`), which has `-host` and `-net` arguments for `route add` commands, that tell the program whether to interpret the address part as a network based on the mask given, or as a single host (where the mask can be omitted.)

`ip route` on the other hand just goes by the mask given similar to `-s` and `-d` in `iptables`, where it really just does as it is told: check this address according to the given mask. And like `iptables`, assumes /32 if no mask is given.

--
gordonfish




[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux