I am using Python 2.7 on Linux. I need to get local IP address (here it is 172.16.x.x). I can get IP address and it's corresponding netmask address but I'm not able to get broadcast IP address for the same IP.
Asked
Active
Viewed 1,724 times
0
-
possible duplicate of [Get IP Mask from IP Address and Mask Length in Python](http://stackoverflow.com/questions/10508560/get-ip-mask-from-ip-address-and-mask-length-in-python) – rth Apr 16 '15 at 08:58
1 Answers
0
If you are able to get the IP and the Subnetmask, you could simply calculate the Broadcastadress, by binary ORing the IP adress and the inverted subnetmask.
BC = ipadress || inv(subnetmask)

Thargor
- 709
- 5
- 19
-
Thanks @Thargor for your help. But find the solution by using ipaddr.IPNetwork(vm).broadcast,got the answer from another post of stack overflow, where vm = ipaddress + "/" +netmask. Thanks both of you for the help – Learner Apr 20 '15 at 13:36