LWN.net Logo

Python and ipaddr.py

Python and ipaddr.py

Posted Jun 18, 2009 12:48 UTC (Thu) by busterb (subscriber, #560)
In reply to: Python and ipaddr.py by gdt
Parent article: Python and ipaddr.py

I've been using libdnet, which is in C, for years, and it also uses the same structure to identify an
address and a subnet. http://libdnet.sourceforge.net/dnet.3.txt An individual host IP is just a /32.

I'm not sure I understand how you can deal with an IP address without also knowing its netmask,
whether you're calling it a subnet or a host IP address. In fact, Linux's tools complain if you try to
manipulate an IP address without the mask:

bcook@target4:~$ sudo ip addr add 2.0.0.1/16 dev test2
bcook@target4:~$ sudo ip addr del 2.0.0.1 dev test2
Warning: Executing wildcard deletion to stay compatible with old scripts.
Explicitly specify the prefix length (2.0.0.1/32) to avoid this warning.
This special behaviour is likely to disappear in further releases,
fix your scripts!


(Log in to post comments)

Python and ipaddr.py

Posted Jun 18, 2009 15:38 UTC (Thu) by johill (subscriber, #25196) [Link]

The 'ip' command behaviour outlined here is because it also conflates the IP address and the network, because it not only deletes the address but also the corresponding route.

Python and ipaddr.py

Posted Jun 18, 2009 20:32 UTC (Thu) by jengelh (subscriber, #33263) [Link]

ip does not delete routes here; the kernel does (AFAICS). You see the same behavior when doing `ip link set eth0 down`.

Python and ipaddr.py

Posted Jun 18, 2009 20:42 UTC (Thu) by johill (subscriber, #25196) [Link]

Ok, so the kernel needs to know the address and netmask and conflates it, not ip. Doesn't change much :)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds