例如地址网络掩码对的:
如何获得CIDR标记法10.66.114.0/24
的较低更高的IP地址在这种情况下,答案是:
10.66.114.1 - 10.66.114.254如何获得IP范围了CIDR标记法或使用Java
2
A
回答
4
下面是它的要点(我是一个C的家伙):
unsigned int network = 0x0a427200; /* 10.66.114.0 */
unsigned int subnet_length = 24;
unsigned int mask = 0xfffffff << (32 - subnet_length);
unsigned int bcast = 0xffffffff >> (32 - subnet_length);
unsigned int start_ip = (network & mask) + 1;
unsigned int end_ip = (network & mask) + (bcast - 1);
-1
#include <ncurses.h>
// ncurses.h includes stdio.h
#include <math.h>
#include <stdlib.h>
// determine network range of masked ip. eg: 192.168.113.0/25
// unsigned int network = 0x0a427200; /* 10.66.114.0 */
// unsigned int subnet_length = 24;
//
// unsigned int mask = 0xfffffff << (32 - subnet_length);
// unsigned int bcast = 0xffffffff >> (32 - subnet_length);
//
// unsigned int start_ip = (network & mask) + 1;
// unsigned int end_ip = (network & mask) + (bcast - 1);
int main(int argc, char *argv[])
{
// char arg[50] = " ";
char ipmask[50] = "192.168.113.0/25";
// determine network range of masked ip. eg: 192.168.113.0/25
unsigned int network = 0xc0a87100; /* 192.168.113.0 */
unsigned int subnet_length = 25;
unsigned int mask = 0xfffffff << (32 - subnet_length);
unsigned int bcast = 0xffffffff >> (subnet_length);
// unsigned int bcast = 0xffffffff >> (32 - subnet_length);
unsigned int start_ip = (network & mask) + 1;
unsigned int end_ip = (network & mask) + (bcast);
initscr();
cbreak();
printw("\nipmask %s\nstart %x end %x range %x\n"
"press any key\n", ipmask, start_ip, end_ip, end_ip - start_ip + 1);
getch();
endwin(); // close ncurses library and restores previous console
return(0);
}
/*****************************************************************************/
// end netmask
gcc -Wall netmask.c -o netmask -lm -lncurses
+0
Errm ...这是C,而不是Java ... – Manu
相关问题
- 1. IP到CIDR/IP范围
- 2. 使用PHP和CIDR计算IP范围
- 3. IP属于CIDR范围
- 4. 如何使用Ruby将IP范围转换为单个CIDR
- 5. 转换IP范围列表来CIDR
- 6. MySQL查询CIDR转换成IP范围
- 7. 从MySQL的IP范围中选择CIDR
- 8. 选择在IP范围内的CIDR
- 9. 比较Ip的范围列表(用CIDR)在Java中
- 10. 了解IP,CIDR以及IP如何映射到CIDR
- 11. 在Ruby/Rails中使用CIDR的IP范围?
- 12. 将IP范围转换为CIDR表示法的模块,脚本或算法
- 13. oracle PL/SQL如何计算IPv6的范围ip cidr
- 14. 使用eval获得范围
- 15. 计算子网CIDR范围
- 16. 查找如果CIDR的IP范围的IP存在手工的Python
- 17. 如何使用.htaccess阻止IP范围
- 18. 获取IP范围与目标C
- 19. 如何在C#中获取IP范围?
- 20. Kubernetes - 以编程方式查找服务IP范围CIDR
- 21. 检查一个IP是否在Python的CIDR范围内
- 22. 从CIDR范围检索最大/最小IP地址
- 23. 从IP范围到CIDR掩码的转换
- 24. 检查IP是否在CIDR网络掩码(范围)
- 25. 我如何获得第一个IP地址范围?
- 26. 如何获得下一个IP的范围从Excel
- 27. 使用ipaddress和输出到数据帧转换CIDR IP地址范围
- 28. 如何将ip1-ip2格式的IP范围转换为cidr格式?
- 29. 如何将CIDR转换为C#中的网络和IP地址范围?
- 30. 如何计算IP范围
重复的http://stackoverflow.com/questions/2942299 /转换-CIDR的地址到子网掩码-一个nd-network-address – bstick12
你的例子是错误的。它是10.66.114.0 - 10.66.114.255 – mailq