Mysql 根据子网掩码计算 IP地址范围 IP最大值最小值

 

 

 

select inet_aton("192.168.1.1");
select bin(inet_aton("192.168.1.1"));



select bin(inet_aton("192.168.1.1")|inet_aton("255.255.254.0"));
select bin(inet_aton("192.168.1.1")&inet_aton("255.255.254.0")),bin(inet_aton("192.168.1.1")&inet_aton("255.255.254.0"));

select bin(inet_aton("255.255.254.0")),bin(inet_aton("255.255.248.0"));
select inet_ntoa(inet_aton("192.168.8.1")&inet_aton("255.255.248.0"));
select bin(inet_aton("255.255.248.0")),bin(inet_aton("255.255.248.0"));


select inet_aton("255.255.255.255")-inet_aton("255.255.248.0"),bin(inet_aton("255.255.255.255")-inet_aton("255.255.248.0"));
select inet_ntoa(inet_aton("192.168.0.1")&inet_aton("255.255.248.0")),
    bin((inet_aton("192.168.0.1")&inet_aton("255.255.248.0"))+(inet_aton("255.255.255.255")-inet_aton("255.255.248.0"))),
    inet_ntoa((inet_aton("192.168.0.1")&inet_aton("255.255.248.0"))+(inet_aton("255.255.255.255")-inet_aton("255.255.248.0")));
posted @ 2021-04-23 15:30  Rocken.li  阅读(258)  评论(0编辑  收藏  举报