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?
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.
- Assign the IP addresses to the interface with a /32 netmask
- 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
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.