import
ipaddress
network
=
ipaddress.IPv4Network(
"192.168.1.0/24"
)
print
(
"Network address of the network:"
, network.network_address)
print
(
"Broadcast address:"
, network.broadcast_address)
print
(
"Network mask:"
, network.netmask)
print
(
"with netmask:"
, network.with_netmask)
print
(
"with_hostmask:"
, network.with_hostmask)
print
(
"Length of network prefix in bits:"
, network.prefixlen)
print
(
"Total number of hosts under the network:"
, network.num_addresses)
print
(
"Overlaps 192.168.0.0/16:"
, network.overlaps(ipaddress.IPv4Network(
"192.168.0.0/16"
)))
print
(
"Supernet:"
, network.supernet(prefixlen_diff
=
1
))
print
(
"The network is subnet of 192.168.0.0/16:"
,
network.subnet_of(ipaddress.IPv4Network(
"192.168.0.0/16"
)))
print
(
"The network is supernet of 192.168.0.0/16:"
,
network.supernet_of(ipaddress.IPv4Network(
"192.168.0.0/16"
)))
print
(
"Compare the network with 192.168.0.0/16:"
,
network.compare_networks(ipaddress.IPv4Network(
"192.168.0.0/16"
)))