network-interface

Linux getting all network interface names

ⅰ亾dé卋堺 提交于 2019-11-27 12:54:31
I need to collect all the interface names, even the ones that aren't up at the moment. Like ifconfig -a . getifaddrs() is iterating through same interface name multiple times. How can I collect all the interface names just once using getifaddrs() ? You could check which entries from getifaddrs belong to the AF_PACKET family. On my system that seems to list all interfaces: struct ifaddrs *addrs,*tmp; getifaddrs(&addrs); tmp = addrs; while (tmp) { if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET) printf("%s\n", tmp->ifa_name); tmp = tmp->ifa_next; } freeifaddrs(addrs); getifaddrs()

What exactly means iOS networking interface name? what's pdp_ip ? what's ap?

邮差的信 提交于 2019-11-27 06:42:50
问题 I use following code to print all interface and it's mac address - ( 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

How do I get the network interface and its right IPv4 address?

吃可爱长大的小学妹 提交于 2019-11-27 00:36:18
I need to know how to get all network interfaces with their IPv4 address. Or just wireless and Ethernet. To get all network interfaces details I use this: foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) { if(ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet) { Console.WriteLine(ni.Name); } } And to get the all hosted IPv4 addresses of the computer: IPAddress [] IPS = Dns.GetHostAddresses(Dns.GetHostName()); foreach (IPAddress ip in IPS) { if (ip.AddressFamily == AddressFamily.InterNetwork) {

Can't connect to cassandra node from different host

允我心安 提交于 2019-11-26 20:28:48
问题 I have a cassandra node at a machine. When I access cqlsh from the same machne it works properly. But when I tried to connect to it's cqlsh using "192.x.x.x" from another machine, I'm getting an error saying Connection error: ('Unable to connect to any servers', {'192.x.x.x': error(111, "Tried connecting to [('192.x.x.x', 9042)]. Last error: Connection refused")}) What is the reason for this? How can I fix it? 回答1: Probably the remote Cassandra node is not bound to the external network

How to Determine Internet Network Interface in Java

萝らか妹 提交于 2019-11-26 20:17:58
问题 How do you determine which network interface is connected to the internet using Java? For example, I run InetAddress.getLocalHost().getHostAddress(); and within Eclipse this returns exactly what I intend, 192.168.1.105. However, if I package this into a jar file and run the program, the code returns 169.254.234.50. Looking into this, I found this is the IP address of a VMware Virtual Ethernet Adapter interface on my machine. Is there any way to determine the interface connected to the

Python: check whether a network interface is up

ぐ巨炮叔叔 提交于 2019-11-26 16:55:39
问题 In Python, is there a way to detect whether a given network interface is up ? In my script, the user specifies a network interface, but I would like to make sure that the interface is up and has been assigned an IP address, before doing anything else. I'm on Linux and I am root . 回答1: The interface can be configured with an IP address and not be up so the accepted answer is wrong. You actually need to check /sys/class/net/<interface>/flags . If the content is in the variable flags, flags &

Linux getting all network interface names

醉酒当歌 提交于 2019-11-26 13:53:18
问题 I need to collect all the interface names, even the ones that aren't up at the moment. Like ifconfig -a . getifaddrs() is iterating through same interface name multiple times. How can I collect all the interface names just once using getifaddrs() ? 回答1: You could check which entries from getifaddrs belong to the AF_PACKET family. On my system that seems to list all interfaces: struct ifaddrs *addrs,*tmp; getifaddrs(&addrs); tmp = addrs; while (tmp) { if (tmp->ifa_addr && tmp->ifa_addr->sa

How do I get the network interface and its right IPv4 address?

99封情书 提交于 2019-11-26 09:26:48
问题 I need to know how to get all network interfaces with their IPv4 address. Or just wireless and Ethernet. To get all network interfaces details I use this: foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) { if(ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet) { Console.WriteLine(ni.Name); } } And to get the all hosted IPv4 addresses of the computer: IPAddress [] IPS = Dns.GetHostAddresses(Dns