我有一个 Linux Docker 容器,它需要一个无线接口才能工作。在 Linux 上(在 Linux 主机上运行它)我没有问题。
带参数运行泊坞窗容器--privileged和--net=host我可以访问该主机的无线接口,并没有任何问题,我可以管理它们。问题是当我在 Mac OS X 主机上运行相同的 Linux Docker 容器时。我看不到 Docker 容器内的无线接口。
这是 Mac OS X v10.12 (Sierra) 主机上 ifconfig 的输出:
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=b<RXCSUM,TXCSUM,VLAN_HWTAGGING>
ether 00:0c:29:fe:78:07
inet6 fe80::8ff:62ac:e141:5aa9%en0 prefixlen 64 secured scopeid 0x4
inet 192.168.0.153 netmask 0xffffff00 broadcast 192.168.0.255 …Run Code Online (Sandbox Code Playgroud) 在 OS X 上,当在所有接口的特定端口上创建服务器套接字时,新的服务器套接字可以绑定到localhost相同的端口并接受连接。我希望绑定会localhost失败,就像在 Linux 中尝试相同时一样(我专门在 Ubuntu 上尝试过)。
OS X 上的行为对我来说很奇怪,因为客户端连接localhost在侦听所有接口时工作,但新服务器可以绑定localhost到同一端口并接受新连接,而不是第一个侦听器。
套接字如何侦听所有接口并防止其他套接字绑定到localhostOS X 上的相同端口?
以下测试在 Mac 上通过,在 Ubuntu 上失败,但在两者上都应该失败。
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.net.Inet4Address;
import java.net.ServerSocket;
public class MinimalTest {
@Test
public void listenOnAllInterfacesAndLocalhost() throws IOException {
final int port = 12340;
try (ServerSocket allInterfaces = new ServerSocket(port);
ServerSocket onlyLocalhost = new ServerSocket(port, 100, Inet4Address.getByName("localhost"));) {
Assert.assertEquals(allInterfaces.getLocalPort(), port);
Assert.assertEquals(onlyLocalhost.getLocalPort(), port);
Assert.assertTrue(allInterfaces.isBound());
Assert.assertTrue(onlyLocalhost.isBound());
}
}
}
Run Code Online (Sandbox Code Playgroud)
我试过的:
我正在尝试从WinPcap获取有关已安装的n/w设备的高级信息的示例.
我甚至按照包括WinPcap库的说明,仍然编译器抱怨pcap_findalldevs_ex未定义
在线if (pcap_findalldevs_ex(source, NULL, &alldevs, errbuf) == -1).
我的代码:
#include "stdafx.h"
#include <stdio.h>
#include "pcap.h"
#include <winsock2.h>
#pragma comment(lib, "ws2_32")
// Function prototypes
void ifprint(pcap_if_t *d);
char *iptos(u_long in);
char* ip6tos(struct sockaddr *sockaddr, char *address, int addrlen);
int _tmain(int argc, _TCHAR* argv[])
{
pcap_if_t *alldevs;
pcap_if_t *d;
char errbuf[PCAP_ERRBUF_SIZE+1];
char source[PCAP_ERRBUF_SIZE+1];
printf("Enter the device you want to list:\n"
"rpcap:// ==> lists interfaces in the local machine\n"
"rpcap://hostname:port ==> lists interfaces in …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
f = urllib2.urlopen(url)
data = f.read()
f.close()
Run Code Online (Sandbox Code Playgroud)
它在具有两个网络接口的计算机上运行.我想指定我希望代码使用哪个接口.具体来说,我希望它使用默认情况下使用的那个...但我可以弄清楚如果我可以选择接口哪个是哪个.
什么是最简单/最好/最pythonic的方式?
这种链路聚合甚至可能吗?
在Windows机器上,有几个第三方应用程序利用绑定和负载平衡多个网络接口来提高吞吐量,例如Connectify Dispatcher.是否有可能为OSX开发这样的应用程序?是否已有任何第三方软件在OSX上执行此操作?我能找到的最接近的东西是IPNetRouterX,我没有用它来绑定USB和WiFi网络接口.
我也在OSX的终端中尝试了以下行:
sudo networksetup -createBond bond0 en1 en3
Run Code Online (Sandbox Code Playgroud)
...其中en1是我的WiFi接口,en3是我的USB网络接口,它只会导致:
** Error: The parameters were not valid.
Run Code Online (Sandbox Code Playgroud)
可能需要某种第二层"魔术胶"才能使其成为一种可能性......但主要是作为Windows程序员,我不确定Apple是否会喜欢允许这种级别的编程访问,考虑他们喜欢的专有权......
知道在这里可以做些什么吗?
这是对这个问题的后续问题:
如何确定哪个网络接口适用于Android中的Wifi,3G,4G(LTE)和VPN?
我得到了网络接口和他们的名字,我需要显示他们的类型列表(VPN,Wifi,3G,4G,本地等).
如何通过界面名称了解每种类型?("本地","eth0"等......).我需要显示名称列表,我可以用它来识别每种类型.
我有一个BeagleBone Black开发板.当我最初购买它时,我将它设置在我的Mac上,并能够毫无问题地进入它.然后,我按照教程一次使用USB与BeagleBone共享我的Mac的互联网,从那时起我就无法从我的Mac上连接到我的BeagleBone.我尝试更新HornDis驱动程序,它没有解决任何问题.
会发生什么事情是我的Mac(Mavericks)检测到BeagleBone驱动器,但它没有出现在网络接口中.因此,我根本无法进入BeagleBone.我试过反复安装FTDI和HornDis驱动程序并没有解决问题.
我真的需要它在我的Mac上工作,我现在有点迷失了.任何帮助将非常感激.我无法在BeagleBone中重新安装操作系统,因为我安装了一些非常重要的项目工作并在BeagleBone中工作,并且不想再次重新安装所有这些包.
谢谢.
ssh beagleboard network-interface osx-mavericks beagleboneblack
我正在使用 Scapy 2.2.0 和 Python 2.6 在 Windows 7 上进行嗅探。我知道您可以iface向该sniff函数提供参数。例如:
sniff(count=5,iface = 'eth0', prn=lambda p:p.show())
Run Code Online (Sandbox Code Playgroud)
如果您不提供此参数,它将在所有接口中进行嗅探。但有没有办法从 3 个接口中选择 2 个呢?像这样的东西:(它不起作用)
sniff(count=5, iface='eth0, eth14', prn=lambda p:p.show())
Run Code Online (Sandbox Code Playgroud) 我编写了以下代码,以获取我在计算机上使用的eth0接口的IPv4地址。但是,fe80:x:x:x:xxx:xxxx:xxxx:xxxx由于我正在查找IPv4地址,因此代码仅查找未返回的代码。
这是代码。
interfaceName = "eth0";
NetworkInterface networkInterface = NetworkInterface.getByName(interfaceName);
Enumeration<InetAddress> inetAddress = networkInterface.getInetAddresses();
InetAddress currentAddress;
currentAddress = inetAddress.nextElement();
while(inetAddress.hasMoreElements())
{
System.out.println(currentAddress);
if(currentAddress instanceof Inet4Address && !currentAddress.isLoopbackAddress())
{
ip = currentAddress.toString();
break;
}
currentAddress = inetAddress.nextElement();
}
Run Code Online (Sandbox Code Playgroud) 我有以下代码,它应该只获取所有活动接口的 IPv4 地址,但它仍然在某些计算机上返回 IPv6 地址。
public static List<List> getIpAddress() {
List<String> ip = new ArrayList<>();
List<List> ipRefined = new ArrayList<>();
try {
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements()) {
NetworkInterface iface = interfaces.nextElement();
if (iface.isLoopback() || !iface.isUp())
continue;
Enumeration<InetAddress> addresses = iface.getInetAddresses();
while(addresses.hasMoreElements()) {
ip.add(addresses.nextElement().getHostAddress());
}
}
} catch (SocketException e) {
throw new RuntimeException(e);
}
for(int x = 0; x < ip.size(); x++){
if(ip.get(x).contains("%")){
try {
if (ip.get(x + 1).contains(".")) {
List<String> tempList = new ArrayList<>();
tempList.add(ip.get(x).substring(ip.get(x).indexOf("%") + 1)); …Run Code Online (Sandbox Code Playgroud) java ×3
macos ×3
ipv4 ×2
networking ×2
python ×2
sockets ×2
android ×1
beagleboard ×1
containers ×1
docker ×1
inetaddress ×1
interface ×1
linux ×1
scapy ×1
ssh ×1
tethering ×1
visual-c++ ×1
wifi ×1
winpcap ×1