循环ip段 转载 出处不明
public
struct
IP
{
public
byte
A;
public
byte
B;
public
byte
C;
public
byte
D;
public
IP(
byte
[] ba)
{
A = ba[0];
B = ba[1];
C = ba[2];
D = ba[3];
}
}
public
static
void
IPSection(IPAddress ip1, IPAddress ip2)
{
IP x =
new
IP(ip1.GetAddressBytes());
IP y =
new
IP(ip2.GetAddressBytes());
byte
secStart = 1;
//这里可以改为0
byte
secEnd = 254;
//这里可以改为255
for
(
byte
a = x.A; a <= y.A; a++)
{
byte
bStart = (a == x.A ? x.B : secStart);
byte
bEnd = (a == y.A ? y.B : secEnd);
for
(
byte
b = bStart; b <= bEnd; b++)
{
byte
cStart = (a == x.A && b == x.B) ? x.C : secStart;
byte
cEnd = (a == y.A && b == y.B) ? y.C : secEnd;
for
(
byte
c = cStart; c <= cEnd; c++)
{
byte
dStart = (a == x.A && b == x.B && c == x.C) ? x.D : secStart;
byte
dEnd = (a == y.A && b == y.B && c == y.C) ? y.D : secEnd;
for
(
byte
d = dStart; d <= dEnd; d++)
{
OutputIpAddress(a, b, c, d);
}
//这个是测试用的,只输出这一网段最后一位的起止位置,不输出全部。
//Output("========输出网段========");
//OutputIpAddress(a, b, c, dStart);
//OutputIpAddress(a, b, c, dEnd);
}
}
}
}
========================
string
ipStr1 =
"1.1.1.1"
;
string
ipStr2 =
"1.1.2.2"
;
string
[] ipArray1 = ipStr1.Split(
new
char
[] {
'.'
});
string
[] ipArray2 = ipStr2.Split(
new
char
[] {
'.'
});
long
ipStart = 256 * 256 * 256 *
long
.Parse(ipArray1[0]) + 256 * 256 *
long
.Parse(ipArray1[1]) + 256 *
long
.Parse(ipArray1[2]) +
long
.Parse(ipArray1[3]);
long
ipEnd = 256 * 256 * 256 *
long
.Parse(ipArray2[0]) + 256 * 256 *
long
.Parse(ipArray2[1]) + 256 *
long
.Parse(ipArray2[2]) +
long
.Parse(ipArray2[3]);
List<
string
> SearchIPArray =
new
List<
string
>();
//存放你的中间IP
for
(
long
i = ipStart; i <= ipEnd; i++)
{
long
tmp = i;
long
a = tmp / (256 * 256 * 256);
tmp -= a * (256 * 256 * 256);
long
b = tmp / (256 * 256);
tmp -= b * 256 * 256;
long
c = tmp / 256;
tmp -= c * 256;
long
d = tmp;
SearchIPArray.Add(a.ToString() +
"."
+ b.ToString() +
"."
+ c.ToString() +
"."
+ d.ToString());
}
循环ip段 转载 出处不明的更多相关文章
- 【转载】IIS6、IIS7、IIS7.5设置拒绝一组计算机(IP段)访问网站的方法
IIS6设置方法: 1.打开IIS管理器,右键点击网站,选择“属性” 2.把标签切换到“目录安全性”,点击“IP地址和域名限制”的编辑按钮,如下图: IP地址和域名限制 3.选择“授权访问”,然后点击 ...
- [转帖]IP地址、子网掩码、网络号、主机号、网络地址、主机地址以及ip段/数字-如192.168.0.1/24是什么意思?
IP地址.子网掩码.网络号.主机号.网络地址.主机地址以及ip段/数字-如192.168.0.1/24是什么意思? 2016年03月26日 23:38:50 JeanCheng 阅读数:105674 ...
- IP段,ASN与BGP之间的关系
概览 IP段就是类似于1.0.2.0-1.0.2.255或者1.0.2.0/24的形式 ASN(Autonomous system number)自治系统编号 BGP(Border Gateway P ...
- 百度蜘蛛IP段分析
大家进行网站日志分析的时候,常见到很多不同IP段的百度蜘蛛,为了方便大家更好的进行日志分析,下面列举了百度不同IP段常见蜘蛛的一些详情情况,及所谓的降权蜘蛛,沙盒蜘蛛,高权重蜘蛛等等 下面的百度蜘蛛I ...
- 一键批量ping任意ip段的存活主机
=======================by me===================================== @echo offecho.color FC for /f %%i ...
- linux编写脚本检测本机链接指定IP段是否畅通
linux编写脚本检测本机链接指定IP段是否畅通,通过ping命令检测指定IP,检测命令执行结果,若为0表示畅通,若为1表示不通,以此判断网络是否畅通,但是指定机器禁用ping命令除外.代码如下: # ...
- bootargs中ip段各项解释
目标板:合众达的SEED-DVS6467开发板 内核版本:2.6.10 最近同事测试板卡nfs挂载PC的文件系统时出现点问题,PC上ifconfig中显示以太网为eth3,然而板卡启动参数列表相关信息 ...
- ip效验和ip段的效验
package com.juchen.utils; import javax.servlet.http.HttpServletRequest; /** * ip 相关的工具方法 */ public ...
- [转帖]Oracle 使用sqlnet.ora/trigger限制/允许某IP或IP段访问指定用户
Oracle 使用sqlnet.ora/trigger限制/允许某IP或IP段访问指定用户 原创 Oracle 作者:maohaiqing0304 时间:2016-05-03 17:05:46 17 ...
随机推荐
- Nginx将项目配置在子目录
问题:一个完整的项目需要整合在另外一个项目中,作为一个子模块存在 有两个项目prject1 根目录/www/project1与project2 /www/project2,现在是想将probject1 ...
- Arduino使用注意问题及编程相关
1.Arduino的概念 arduino是一款便捷灵活方便上手的开源电子原型平台,包含硬件(各种型号的arduino板)和软件(arduino IDE), 是一个基于开放原始码的软硬件平台,构建于开放 ...
- URAL 1525 Path
#include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> us ...
- 第一百零八节,JavaScript,内置对象,Global对象字符串编码解码,Math对象数学公式
JavaScript,内置对象,Global对象字符串编码解码,Math对象数学公式 学习要点: 1.Global对象 2.Math对象 ECMA-262对内置对象的定义是:"由ECMASc ...
- String.getBytes()--->字符串转字节数组
是String的一个方法String的getBytes()方法是得到一个系统默认的编码格式的字节数组getBytes("utf-8") 得到一个UTF-8格式的字节数组把Strin ...
- 草料生成app自动下载的二维码
草料官网http://cli.im/app 填写iOS和安卓的appid就好了
- JavaScript面向对象基础语法总结
1.Javascript的 对象(Object): //例子:var car = { , , }; 2.使用构造函数来创建对象. //例子: var Car = function() { ; ; ; ...
- 对于querystring取值时候发生+号变空格的问题
今天遇到这个问题,在网上找了几个答案,解决了问题,很高兴,所以贴出来给大家分享一下: URL如下 http://127.0.0.1/test/test.aspx?sql= and id='300+' ...
- .Net Core 学习资料
官方网站:https://www.microsoft.com/net/core#windows 官方文档:https://docs.asp.net/en/latest/intro.html 中 ...
- 让 idea webstorm phpstorm 能够 识别 thinkphp 的方法(自动提示功能)
1.在/ThinkPHP/Library/Think 目录下 新建一个文件,名为: BaseController.class.php 2.BaseController.class.php 内容为 n ...