Get client source IP on docker for Windows - docker

I have a docker container running on a Windows Server host, it has a Java app running which communicates with remote client bidirectionally, when the remote client communicates with my server it gets the Docker gateway ip, 10.1.0.1 instead of the remote ip;
It only happens on Windows host, with an Ubuntu Server host it works without any trouble, I get the remote client ip, which I need to answer the petition.
Things I tried:
Disable ip masquerading from docker-compose.yaml file with;
com.docker.network.bridge.enable_ip_masquerade: 'false'
Disable ip masquerading from daemon.json with;
"ip-mask": false
This is how I create the network on docker-compose.yaml;
Nothing of these two solutions worked, thanks in advance.

Related

connect ECONNREFUSED 127.0.0.1:8046 when connecting to host app from Docker container - Windows 10

I have a standalone app running on my machine (not in a docker container) listening to port 8046 (localhost:8046) using an ngrok tunnel (http ngrok 8046). I am trying to connect to it sending a POST from my docker container which I'm also running on my local machine using http://host.docker.internal:8046. I have tried many different approaches but nothing seems to work:
I have tried to disable my firewall to make sure that wasn't the issue.
Tried http://localhost:8046 in the container to connect to the app
Tried serving the standalone app on 0.0.0.0 with the same port 8046 and setting http://0.0.0.0:8046 in the container to connect to it, unsuccessfully
I keep having connect ECONNREFUSED 127.0.0.1:8046
my etc/hosts is configured with the IP added by docker desktop for host.docker.internal and gateway.docker.internal
I'm running out of ideas and can't figure out what I could be missing. Any ideas? Thanks in advance
Inside container localhost, 127.0.0.1, 0.0.0.0 represent the container itself. To connect to the host machine please try using its domain name or IP address in the LAN, which the host machine belongs to.

Can't connect to docker container running minecraft server online

So I've been trying to host my own Minecraft server for a while now and I hit a snag.
I have proxmox (192.168.2.100) running an ubuntnu server VM (192.168.2.101) which has a docker container running my Minecraft server. I can connect to the server locally just fine using the ubuntu's IP address and minecraft port, but when I try to port forward the server, I can't connect to it. I checked to see if my port was exposed or not and it is so I know it's not that.
This is the container that I'm using
Okay, so after a long time looking at configurations and some help from the proxmox forum, it turns out that my modem doesn't support NAT reflection which means that any attempts to access my server though my public IP on the same network wouldn't work at all. I used my phone's mobile network to test if I could access the server from outside my local network and it worked just fine!

Install Jenkins on windows server and access it using VM's external ip [google-compute-engine]

I have created a VM instance with windows OS (windows-server-2019-dc-v20200211) in Google cloud.Established RDP connection and installed Jenkins on the VM, but how can I access it from other networks using the VM's external ip?
Could someone help me on this!!
Note: I want to install Jenkins in windows server and not on Linux.
I'll suggest you should check the following:
First, make sure your local firewall on windows server is enabled and allows connections on port 8080. Secondly, Network ACL for both incoming traffic on TCP 8080 and outcoming traffic on TCP port 8080 should be allowed.
Also check some of these stackoverflow use cases for more help: [1]https://superuser.com/questions/1212645/cannot-expose-jenkins-externally [2]https://apple.stackexchange.com/questions/31376/how-can-i-open-port-8080-of-mac-os-x-lion [3] Jenkins server is not accessible by host name (ip address)

Connecting to BACNET Server on Host Machine Using Client Container

I am trying to connect my BACNET client which has been containerized and the BACNET server which is running on the host machine. I am using Docker for Windows on Windows 10 (host machine) with Linux containers.
I have tried the following:
a. Publishing the ports 47808 for the client container with the run command.
b. Running the container with network=host, to access services of localhost.
c. Tried specifying the gateway IP as the server's IP address with run command.
d. Running the container in the same subnet as my server
e. Running the container with the host IP specified and the ports published.
My bacnet server, taken from https://sourceforge.net/projects/bacnet/ always connects to the DockerNAT, 10.0.75.1? Any idea why does this happens? The server application is not a container but an executable file.
Server IP:10.0.75.1 (dockerNAT)
Client container running on host machine.
From a quick google:
For Windows containers this component is not used and containers and
their ports are only accessible via the NATed IP address.
With respect to BACnet, this is going to put you in a world of hurt. You will have to use BACnet BBMD with NAT support in your container to achieve this, and your BACnet Client will have to register as a BACnet Foreign Device. The BACnet Stack at SourceForge does seem to have some NAT support (the code seems to be there but I have never tested it in its original form).
So what you are seeing is 'expected', but your solution is going to require that you become much more familiar with BACnet BBMDs than you ever want to be. Read the BACnet specification carefully. Good luck.

Docker network settings and iptables NAT

I have a server running inside a docker container, listening on UDP port, let's say 1234. This port is exposed in Dockerfile.
Also, I have an external server helping with NAT traversal, basically, just sending addresses of the registered server and a client to each other, and allowing to connect to a server by the name it sent during registration.
Now, if I run my container with -P option, my port is getting published as some random port, e.g. 32774. But on the helper server I see my server connected to it from port 1234, and so it can't send a correct address to a client. And a client can't connect at all.
If I run my container explicitly publishing my server on the same port with -p 1234:1234/udp, a client can connect to my server directly. But now on the helper server I see my server connected to it from port 1236, and again it can't send the correct port to a client.
How can this be resolved? My aim is to require as little addition configuration as possible from people who will use my docker image.
EDIT: So, I need either to know my external port number from inside the container to send it to the discovery server, which, as I understand, not possible at the moment, right? Or I need to make outgoing connections from the container and my port to use the same external port as configured for incoming connections - is that possible?
The ports are managed by docker and the docker network adaptor. When using solely -P then the port is exposed docker internally and accessible through docker linking. When using "1234:1234" then the port is mapped on a host port and directly available for a client and also available for linking.
Start the helper server with a link option "--link server container/name". The helper server will connect to host "server" on port 1234. The correct ip address will be managed by docker.
Enable docker to change your iptables configuration, which is docker default. Afterwards the client should be able to connect to both instances. Note that the helper server should provide the host ip and not the docker container ip address. The docker container ip address does only work inside the host where the docker network adapter is running.

Resources