March 2019
Beginner
490 pages
12h 40m
English
Let's import the ipaddress module and define a net4 network:
>>> import ipaddress>>> net4 = ipaddress.ip_network('10.0.1.0/24')
Now, we can find some useful information, such as netmask and the network/broadcast address, of net4:
>>> net4.netmask IP4Address(255.255.255.0)
The netmask properties of net4 will be displayed as an IP4Address object. If you are looking for its string representation, then you can call the str() method, as shown here:
>>> str(net4.netmask) '255.255.255.0'
Similarly, you can find the network and the broadcast addresses of net4 by using the following code:
>>> str(net4.network_address) 10.0.1.0>>> str(net4.broadcast_address) 10.0.1.255
We can get the number of addresses net4 can hold with the following ...
Read now
Unlock full access