Score:0

Netplan static IP subnets - am I accidentally adding extra IPs?

ar flag

I'm not sure if this is the right place to ask this so sorry if not. I've configured a machine running ubuntu server on my network to have two local static IPs like so:

network:
  ethernets:
    enp0s3:
      addresses:
      - 192.168.1.155/24
      - 192.168.1.156/24
      gateway4: 192.168.1.1
      nameservers:
        addresses:
        - 1.1.1.1
        - 1.0.0.1
  version: 2

With this I can ping my machine with both 192.168.1.155 and 192.168.1.156.

Now I'm new to networking but I know that the a /24 mask means all the addresses in the 192.168.1 range, but what does it mean in the case of netplan when I'm supposed to be giving specific IP addresses? Am I allocating more IPs by accident? What would happen if I changed it to /32? Thanks.

Doug Smythies avatar
gn flag
with the /24 you are defining your sub-net mask of 24 bits. No, you are not allocating more IP's by accident. Do not change it to /32.
Letal1s avatar
ar flag
So is the 24 bit mask where it can access any other devices in 192.168.1.0 without the gateway? I'm assuming changing to /32 would take away my LAN access?
us flag
That's correct. The netmask declares the range of other ips on the local network.
Score:0
cn flag

In the case of netplan's address configuration entry, /24 indicates the netmask of the network the specified address belongs to, and hence the range of addresses which are directly reachable through that interface.

  addresses:
  - 192.168.1.155/24

means: "Assign the interface the IPv4 address 192.168.1.155 and the netmask /24." So if you later do a ping 192.168.1.234 the OS will know that the destination address is on the same network and try to locate it via ARP (in the case of Ethernet).

  addresses:
  - 192.168.1.155/24
  - 192.168.1.156/24

will assign two addresses within the same subnet, setting the netmask to /24 both times, somewhat redundantly.

If you changed it to /32 then the netmask of the interface would be set to /32 instead, meaning that no other addresses except those of the interface itself are directly reachable through it. So ping 192.168.1.234 would look for a suitable next hop in the routing table, probably hitting the default gateway. If the default gateway is itself in the 192.168.1.0/24 network then it will not be reachable either, so a routing error will occur.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.