我需要知道如何使用其IPv4地址获取所有网络接口.或者只是无线和以太网.
要获取所有网络接口详细信息,我使用此:
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) {
if(ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 ||
ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet) {
Console.WriteLine(ni.Name);
}
}
Run Code Online (Sandbox Code Playgroud)
并获取计算机的所有托管IPv4地址:
IPAddress [] IPS = Dns.GetHostAddresses(Dns.GetHostName());
foreach (IPAddress ip in IPS) {
if (ip.AddressFamily == AddressFamily.InterNetwork) {
Console.WriteLine("IP address: " + ip);
}
}
Run Code Online (Sandbox Code Playgroud)
但是如何获得网络接口及其正确的ipv4地址?
我试图删除aws vpc(非默认值).我收到错误"我们无法删除以下VPC(vpc-xxxxxxx(xx.xx.xx.x/16))网络接口'eni-xxxxxx'目前正在使用中.(服务:AmazonEC2;状态代码:400 ;错误代码:InvalidParameterValue;请求ID:xxxxxx-dd86-47c8-98cd-xxxxxxxxxxx)".
当我尝试删除相关的网络接口时,出现错误"eni-xxxxxxx:您无权访问指定的资源."
有一些与NI(网络接口)相关的安全组.有与NI相关的子网.没有EC2实例 - 所有实例都被终止.没有VPC端点.没有RDS db,db安全组或子网.
对于EC2 SG(安全组),我在尝试删除时收到权限被拒绝错误消息(甚至非默认SG对非默认VPC.此SG描述了"AWS为d-xxxxxxxxxx目录控制器创建的安全组".
对于子网,我无法删除它们,因为它们与上述NI相关联.
有人可以帮忙吗?我有一个免费的等级帐户,因此甚至没有技术支持或者都无法在aws论坛中发布新帖子(收到错误消息 - 您的帐户尚未准备好发布消息.请稍后再试).我担心这是因为我有一个免费的等级帐户.
我有一台带有两个网络接口的PC:eth0和eth1.
eth0 - ip为192.168.11.X/24.
eth1 - ip为192.168.130.X/24.eth1具有互联网连接.
当我尝试连接到互联网时,我的操作系统如何知道使用哪个界面?它是否遍历所有默认网关?它是否具有每个接口提供的缓存?Windows和Linux之间的行为有什么不同吗?
我正在运行Windows 10,VirtualBox 5和Vagrant 1.7.4并尝试运行openx平台.
我跑完后vagrant up得到:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set network interfaces...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["hostonlyif", "ipconfig", "VirtualBox Host-Only Ethernet Adapter #25", "--ip", "192.168.33.1", "--netmask", "255.255.255.0"]
Stderr: VBoxManage.exe: error: The host network interface with the given name could not be found
VBoxManage.exe: error: Details: code E_INVALIDARG (0x80070057), component HostWrap, …Run Code Online (Sandbox Code Playgroud) 我在一台机器上有一个cassandra节点.当我从同一个机器上访问cqlsh时,它可以正常工作.
但当我尝试使用另一台机器上的"192.xxx"连接到它的cqlsh时,我收到一个错误说
连接错误:('无法连接到任何服务器',{'192.xxx':错误(111,"尝试连接到[('192.xxx',9042)].上次错误:连接被拒绝")})
这是什么原因?我该如何解决?
如何确定使用Java连接到Internet的网络接口?例如,我跑
InetAddress.getLocalHost().getHostAddress();
Run Code Online (Sandbox Code Playgroud)
在Eclipse中,这完全返回我想要的内容,192.168.1.105.但是,如果我将其打包到jar文件并运行该程序,则代码返回169.254.234.50.看看这个,我发现这是我机器上的VMware虚拟以太网适配器接口的IP地址.
有没有办法确定连接到互联网的接口,但同时保持我的代码的可移植性?
接口比较
界面[net4]
display name : Intel(R) Centrino(R) Ultimate-N 6300 AGN
MTU : 1500
loopback : false
point to point: false
up : true
virtual : false
multicast : true
HW address : 00 24 D7 2C 5F 70
INET address (IPv4): 192.168.1.105
host name : MyComputer
canonical host name : MyComputer
loopback : false
site local : true
any local : false
link local : false
multicast : false
reachable : true
Run Code Online (Sandbox Code Playgroud)
界面[eth5]
display name : …Run Code Online (Sandbox Code Playgroud) 我需要收集所有的接口名称,即使是目前尚未启动的接口名称.喜欢ifconfig -a.
getifaddrs()正在多次迭代相同的接口名称.如何只使用一次收集所有界面名称getifaddrs()?
我使用以下代码打印所有接口及其mac地址
- ( void )interfaceInfo{
int mib[6];
size_t len;
char *buf;
unsigned char *ptr;
struct if_msghdr *ifm;
struct sockaddr_dl *sdl;
mib[0] = CTL_NET;
mib[1] = AF_ROUTE;
mib[2] = 0;
mib[3] = AF_LINK;
mib[4] = NET_RT_IFLIST;
char name[128];
memset(name, 0, sizeof(name));
for (int i=1; i<20; i ++) {
if (if_indextoname(i, name)) {
printf("%s ",name);
}else{
continue;
}
if ((mib[5] = if_nametoindex(name)) == 0) {
printf("Error: if_nametoindex error\n");
return NULL;
}
if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
printf("Error: …Run Code Online (Sandbox Code Playgroud) 当我尝试为仅主机网络添加新的网络接口时,Virtual Box版本:版本5.0.22 r108108.
我收到以下错误:
Could not find Host Interface Networking driver! Please reinstall.
Result Code:
E_FAIL (0x80004005)
Component:
HostNetworkInterfaceWrap
Interface:
IHostNetworkInterface {455f8c45-44a0-a470-ba20-27890b96dba9}
我想用C#.NET我知道,它可以使用来计算通过网络接口,以获得准确的下载/上传速度GetIPv4Statistics().BytesReceived,并把线程睡眠一段时间.但是它没有给出我在浏览器中得到的输出.
c# ×2
virtualbox ×2
.net ×1
amazon-ec2 ×1
amazon-vpc ×1
c ×1
cassandra ×1
cqlsh ×1
datastax ×1
ios ×1
ip-address ×1
iphone ×1
java ×1
linux ×1
mac-address ×1
networking ×1
objective-c ×1
openedx ×1
sockets ×1
vagrant ×1