Álv*_*lez 7 networking windows-7 64-bit lan
我在 DHCP 的帮助下连接到 LAN。有时,我需要使用某人带到办公室的未配置为使用 DHCP 的笔记本电脑。到目前为止,我需要执行以下操作:
在我的旧电脑 (Windows XP) 中,我找到了一个技巧来配置我的网卡以同时使用第二个 IP/掩码,这样我就不需要摆弄客户的笔记本电脑设置。遗憾的是,我丢失了链接,并且找不到合适的搜索词来再次找到它。
我怎样才能完成它?
编辑:我找到了链接(配置虚拟 IP 地址),但该程序在我的 Windows 7 机器上ipconfig /all不起作用:不显示新地址,我什至无法 ping 自己 :(
如果NIC 未设置为 DHCP,您可以向正常的 NIC 添加第二个 IP 。
这意味着您要么:
(在 XP 中)

(在win7中)

http://answers.microsoft.com将此作为适用于 win 7 的 C 锐解决方案:
但是它没有解释它为什么工作、如何工作或如何使用它。
公共类 IPAdder
{
[DllImport("iphlpapi.dll", EntryPoint = "AddIPAddress", SetLastError = true)]
private static extern UInt32 MyAddIPAddress(UInt32 Address, UInt32 IpMaskint, int IfIndex,
out IntPtr NTEContext, out IntPtr NTEInstance);
公共 IPAdder()
{ }
public static void AddIPAddress(String IPAddress, String SubnetMask, int ifIndex)
{
系统网。
IPAddress IPAdd = System.Net.IPAddress.Parse(IPAddress);
系统网。
IPAddress SubNet = System.Net.IPAddress.Parse(SubnetMask);
不安全
{
int MyNTEContext = 0;
int MyNTEInstance = 0;
IntPtr ptrMyNTEContext = new IntPtr(MyNTEContext);
IntPtr ptrMyNTEInstance = new IntPtr(MyNTEInstance);
UInt32 结果 = MyAddIPAddress((uint)IPAdd.Address,
(uint)SubNet.Address,ifIndex, out ptrMyNTEContext, out ptrMyNTEInstance);
};
}
}
公共 IP 地址 Get37()
{
IPAddress ipa = IPAddress.Any;
// 检查网络接口
foreach(NetworkInterface.GetAllNetworkInterfaces() 中的 NetworkInterface ni)
{
if ((ni.OperationalStatus != OperationalStatus.Up) ||
(ni.NetworkInterfaceType ==NetworkInterfaceType.Loopback) ||
(ni.NetworkInterfaceType == NetworkInterfaceType.Tunnel))
继续;
if ((ni.Description.IndexOf("virtual", StringComparison.OrdinalIgnoreCase) >= 0) ||
(ni.Name.IndexOf("virtual", StringComparison.OrdinalIgnoreCase) >= 0))
继续;
if (ni.Description.Equals("Microsoft Loopback Adapter", StringComparison.OrdinalIgnoreCase))
继续;
IPInterfaceProperties ipip = ni.GetIPProperties();
bool found37 = false;
foreach (IPAddressInformation unic in ipip.UnicastAddresses)
{
字符串条 = unic.Address.ToString();
if (strip == "37.0.0.1")
{
ipa = unic.Address;
found37 = 真;
休息;
}
}
如果(!找到37)
{
IPAdder.AddIPAddress("37.0.0.1", "255.255.255.0",
(int)(uint)ni.GetType().GetField("index", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(ni));
ipa =IPAddress.Parse("37.0.0.1");
}
休息;
}
返回ipa;
}
[编辑2]
如果允许使用外部软件,那么Win IP config似乎可以完成这项工作。
(截图来自 v2.7。链接现在已更改为 v4 )。
