TCP-Socket到虚拟机的IP地址
IP adress for TCP-Socket to virtual machine
我想在我的windows-pc和linux虚拟机之间建立套接字通信。windows机器是服务器。我写了一个c++程序,在winpc上设置服务器和一个python程序,在VM上设置客户端,但是我如何连接它们?我使用SOCK_STREAM
和AF_INET
,所以我需要一个端口和ip地址连接到服务器。我只是想知道我应该使用什么ip地址,因为它不与IPv4一起工作,这是因为它是错误的ip地址还是因为我的程序中的错误?
编辑1:抱歉数据不足:
我使用Oracle Virtual Box,它的网络配置被设置为default, NAT。当我在host (windows) cmd中运行ipconfig时。我得到了多个ip地址:
Windows IP Configuration Wireless LAN adapter Wireless Network Connection: Media State . . . . . . . . . . . : * Connection-specific DNS Suffix . : * Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : ******** Link-local IPv6 Address . . . . . : * IPv4 Address. . . . . . . . . . . : * Subnet Mask . . . . . . . . . . . : * Default Gateway . . . . . . . . . : * **Ethernet adapter VirtualBox Host-Only Network: Connection-specific DNS Suffix . :* Link-local IPv6 Address . . . . . : * Autoconfiguration IPv4 Address. . : * Subnet Mask . . . . . . . . . . . : '* Default Gateway . . . . . . . . . :*** Tunnel adapter isatap.{*}: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Tunnel adapter 6TO4 Adapter: Connection-specific DNS Suffix . : ******** IPv6 Address. . . . . . . . . . . : * Default Gateway . . . . . . . . . : Tunnel adapter isatap.{5289AB9F-2C9F-4CBE-B826-149B3CFBB45F}: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :* Tunnel adapter isatap.******: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : ******* Tunnel adapter Teredo Tunneling Pseudo-Interface: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . :*
我倾向于认为"以太网适配器VirtualBox主机专用网络"下的ipv6地址是正确的。我试着对lan地址和VirtualBox的纯主机网络地址都进行了ping,都有结果。我也试过tracerout在终端,但没有工作。有什么想法?
我使用"以太网适配器本地连接,链路到链路IPv6"。在阅读了NAT之后,我想这是有道理的!
相关文章:
- 如何使用 Boost Asio 在 Android 上获取我的本地 udp IP 地址?
- C++ / Qt:如何检测主机名或IP地址何时引用当前系统?
- 使用 C++将 IP 地址附加到字符*
- 使用全局 IP 地址时,C++ winsock 2 应用程序中的代码是否必须更改?
- Rabbitmq 将本地主机更改为 IP 地址C++
- C++ - 使用代码块从文件中读取 IP 地址
- C 使用from_string创建IP地址的C 导致lambda错误
- 如何在解析过程中区分 IP 地址和域名
- 如何使用 asio 库获取 IP 地址的主机名
- IP地址匹配过滤功能
- 如何将C++ ulong 4 字节 IP 地址正确转换为 C# 类型
- 如何在NS3中设置节点的IP地址和数据?
- 如何从活动的 udp 连接获取远程 IP 地址和端口
- 无符号的 int 到 IP 地址字符串,不带 itoa/to_string/boost
- 如何在FD_SET内获取套接字的IP地址
- 使用Boost库中的PC中获取我的以太网设备IP地址的列表
- 使用静态IP地址时,ESP32 httpclient连接拒绝了
- C++检查有效的 IP 地址或 IP
- 如何使用 Poco::Net::HTTPSClientSession 绑定特定的源 IP 地址
- 如何在Windows上绕过主机文件获取真实的IP地址