简体   繁体   English

如何从VM访问外网的openstack vm实例

[英]How to access the openstack vm instance from external network from VM

I have the following scenario, I have two file client and server file which is containerised using docker containers.我有以下场景,我有两个文件客户端和服务器文件,它们使用 docker 容器进行容器化。 Client container is residing on a VM using a virtual box (network set using NAT and host-only adapter) and server container is residing on OpenStack VM.客户端容器驻留在使用虚拟机(使用 NAT 和仅主机适配器的网络集)的 VM 上,而服务器容器驻留在 OpenStack VM 上。
The IP address of the server is 192.168.160.39 and the VM machine IP address is enp0s8:192.168.56.108.服务器的IP地址为192.168.160.39,VM机器IP地址为enp0s8:192.168.56.108。 I am running the docker container client as我正在运行 docker 容器客户端

docker run --rm -it -p 192.168.56.108:5555:5555 client bash

and running server docker container as并将服务器 docker 容器作为

docker run --rm -it -p 5555:5555 server bash 

Client.py客户端.py

context = zmq.Context()
#Socket to talk to server
socket = context.socket( zmq.REQ )
socket.connect( "tcp://192.168.160.39:5555" )
name = "Max"
while True:
  message = input( "Message: " )
  socket.send_pyobj( {1: [name, message]} )

Server.py服务器.py

context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://0.0.0.0:5555")
while True:
   #Wait for next request from client
   message = socket.recv_pyobj()
   print("%s: %s" % (message.get(1)[0], message.get(1)[1]))

I am able to access OpenStack VM by ssh from my VM using ssh -J proxy-server OpenStack VM.我可以使用 ssh -J 代理服务器 OpenStack VM 通过 ssh 从我的 VM 访问 OpenStack VM。 for instance ssh -J 4020343@hpdc.xxx.xx ubuntu@192.168.160.39例如 ssh -J 4020343@hpdc.xxx.xx ubuntu@192.168.160.39

My server is unable to retrieve the data from the client.我的服务器无法从客户端检索数据。 Thanks, help is highly appreciated helping me in sorting out this issue.谢谢,非常感谢帮助我解决这个问题。

If you have an openstack instance id, you can find the right sec.如果你有一个 openstack 实例 ID,你可以找到正确的秒。 group with:分组:

example:例子:

openstack server show  284c39d2-79af-485d-8f63-9ac3620cf119 | grep security_groups 

Have you checked the security groups?你检查过安全组吗? The port in which your server is listening (5555) should be opened in the VM that is in OpenStack.服务器正在侦听的端口 (5555) 应该在 OpenStack 中的 VM 中打开。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 与目标 VM 断开连接 - Disconnected from the target VM fcopy使用tcl将文件从主机复制到vm - fcopy to copy a file from host to vm using tcl 与目标 VM 断开连接,地址:'127.0.0.1:51928',传输:'socket' - Disconnected from the target VM, address: '127.0.0.1:51928', transport: 'socket' 找出当前Java VM中打开的网络套接字 - Finding out what network sockets are open in the current Java VM 如何通过开放外壳端口使用python套接字访问Metasploitable 2 VM外壳? - How can I access Metasploitable 2 VM shell with python socket through open shell port? 无法使用UDP从我的VirtualBox debian linux VM发送或接收数据包 - Cannot send or receive packets from my VirtualBox debian linux VM using UDP 使用Java中的套接字编程将数据流从客户端程序(在VM中运行)发送到服务器程序(在Host OS上) - Send stream of Data from client program (running in VM) to server program(on Host OS) using socket programming in Java 与目标 VM 断开连接,地址:'localhost:8613',传输:'socket' 用于 Android Studios 版本 2.2.2 - Disconnected from the target VM, address: 'localhost:8613', transport: 'socket' for Android Studios version 2.2.2 将数据流从VM套接字/远程套接字发送到在主机OS上运行的Flink程序 - send dataStream from VM socket / remote socket to Flink program running on Host OS 如何从另一台计算机和网络访问我的 C 语言套接字服务器? - How to access my socket server in C language from another computer and network?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM