1

I know that it's not recommended to assign the network and broadcast addresses to a host but is there any way/hack using which you can assign them?

  • Sending to either the network address or the broadcast address will send the traffic to all the hosts on the network. There are two exceptions: /31 and /32 networks. With /31 networks, there is only one other host, so that works, and with /32 networks, there are no other hosts. – Ron Maupin Jan 3 '17 at 15:20
0

On linux it is possible to create a network where the first and last addresses are not special and can be used as regular host addresses as follows.

  1. Assign the IP addresses to the interface with a /32 netmask
  2. Add an explicit route with the netmask you want.

I do not know if the same trick will work on other operating systems.

Here is an example that creates two network namespaces and a virtual network between them using the .0 and .255 addresses.

ip netns add blue
ip netns add red
ip netns exec red ip link set dev lo up
ip netns exec blue ip link set dev lo up
ip link add veth0 type veth peer name veth1
ip link set veth0 netns red
ip link set veth1 netns blue
ip netns exec red ip link set dev veth0 up
ip netns exec red ip addr add 192.168.168.0/32 dev veth0
ip netns exec red ip route add 192.168.168.0/24 dev veth0
ip netns exec blue ip link set dev veth1 up
ip netns exec blue ip addr add 192.168.168.255/32 dev veth1
ip netns exec blue ip route add 192.168.168.0/24 dev veth1
ip netns exec red ping 192.168.168.255
ip netns exec blue ping 192.168.168.0
1

You will often see this scenario on point to point links. eg. (172.16.0.0/31 and 172.16.0.1/31). RFC 3021 describes this situation for conserving address space. Packetlife has a good blog post about this as well.

1

There is no need to assign a broadcast or network address to a host. When you have assigned an address to a host, based on the subnetmask, the host will calculate based on the mask what to use for network and broadcast.

On Linux hosts you can already add the network and broadcast address in the interface file but I have no idea what the point of it is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.