From: Boyd Adamson Date: 2005-01-11T07:36:20+09:00 Subject: Re: Standardlib "ipaddr.rb" Markus Werner writes: > Dear "E S", > thanks for you answer. > >> Not really. There is no such IP address as 192.168.1.1/32. There's >> just the IP address 192.168.1.1 and the subnet it may be a part of. > > So far I know it is a valid address. This is just not true. Try "ping 192.168.1.1/32". > I'm the opionion that nowadays a IP Address is only usefull for > networking if you know the netmask too. Also not true. The only netmask a machine needs to know is its own, to determine if a destination machine is on-link or not. Remember that it's far more common to handle the IP addresses of remote machines, where we don't neccesarily know (or need) what their netmask is. The DNS doesn't return the netmask of a remote machine, only the IP address. The internet seems to still work mostly ;-) > So I handle write down IP's always as 172.17.3.5/prefix_length, which > could be also '32'. But sure I'm a admin, so I'm lazy. And in clear > cases I don't write /32 at all. IP addresses as we know them existed long before the "/yy" prefix notation was developed. It's certainly convenient but it's only needed for local machine configuration. It's also used for route entries, firewall rules, access lists, etc. But in all those cases it's a form of shorthand, and never a part of the IP address. >> I understand the confusion, but the proper solution is not to change >> IPAddr to store your notation but to create two separate classes, >> IPAddr and Subnet (or CIDR or whatever). The reason for this is that >> any entity that needs to know what subnet should be used to interpret >> a given IP address should /already know/ what that subnet is. > > Hmmm... Maybe we think a bit different. I would use IPAddr for > storing IPaddresses and get infomation based on this addresses, like > Networkaddress aso. (Why should I store the same thing twice, if I > have already an object who knows about). > > So I say it is still a failure that the IPAddress I gave to IPAddr is > converted automatically to a different value. And in anycase I state > that IPAddr, should reject wrong values and not change a value to > different one. > > I'm inclined to agree that a library for handling IP addresses should provide some support for handling netmasking, but that functionality doesn't belong in a class representing IP addresses. An IP address class should represent just that - the information needed to establish a TCP session for example. Subnets are NOT IP addresses. Netmasks are NOT IP addresses. Just my $0.02