March 2019
Beginner
490 pages
12h 40m
English
In this example, the loopback interface is defined with the 127.0.0.1 IP address. As you can see, the is_loopback property returns True:
>>> loopback = ipaddress.IPv4Interface('127.0.0.1')>>> loopback.is_private True>>> loopback.is_reserved False>>> loopback.is_multicast False>>> loopback.is_loopback True
The IP address classes have many more interesting properties. You can perform some arithmetic and logical operations on those objects. For example, we can check whether an IP address is part of a network.
In this example, we are checking whether an IP address is part of a specific network. Here, a network called net has been defined by the network address, which is 192.168.1.0/24, and the membership of eth0 and eth1 has ...
Read now
Unlock full access