mysql获取IP网段的网络地址和广播地址

比如网段为192.168.1.1/24的IP网段地址,其网络地址及广播地址的数值及字符串表示形式分别为:

网络地址数值:select conv(concat(repeat('1',24),repeat('0',8)),2,10) & INET_ATON('192.168.1.1');

网络地址字符串表示形式:select INET_NTOA(conv(concat(repeat('1',24),repeat('0',8)),2,10) & INET_ATON('192.168.1.1'));

广播地址数值:select conv(concat(repeat('0',24),repeat('1',8)),2,10) | INET_ATON('192.168.1.1');

广播地址字符串表示形式:select INET_NTOA(conv(concat(repeat('0',24),repeat('1',8)),2,10) | INET_ATON('192.168.1.1'));

 

posted @ 2013-01-23 12:38  therockthe  阅读(545)  评论(0)    收藏  举报