When I connect to a remote database from a Docker container, what IP address does the remote see? - docker

I have Docker containers which use a bridge network with subnet 172.16.238.0/24 and I'm connecting to external databases. (Successfully.)
What I'd like to know, though, is: what IP address does the remote database see the connection as coming from? Does it see an address in the subnet address range on any of the packets that it receives?

If it is a remote server, it will see the public IP of the host, which is running the docker container/docker service.

Okay, thank you Husein ... I'll call it "answered."
The reason for my question is that I'm getting an unexpected security-error from an AS/400 DB2 database when I think I'm giving it the right password. I just wanted to make sure that a 172.16.238.xxx IP-address wasn't showing up in any of the internal fields of the packet that the remote database might be examining. (Naturally, this database is well-protected.) I'll follow up with the friendly DBA's now ... and if they say anything interesting I'll add it to this or another ticket.

Related

Connect ASP.NET Core container to remote SQL Server

I am trying to connect my ASP.NET Core application to a remote SQL Server.
The application is deployed using IIS WScore 2016 image. When I run the application on my host, it's working, but in the container using this connection string :
Data Source=xx.xxx.xx.xx,1433;Initial Catalog=somedb;User Id=xxxxxx;Password=xxxxx;
or:
Server=xx.xx.xx.xx,PORT_NB;Database=DATABASE;User Id=USER;Password=PASSWORD
But no luck - I am using the default Docker network.
The error is like this:
Error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - No such host is known.)
Notes:
The server is allowing the remote connection
All the connection strings are tested and can connect to the remote SQL Server from the application that runs on the host
I have read the Docker documentation and they mentioned the IP forwarding but the example was on linux containers and I did not find any help about connecting the Windows containers to a remote SQL Server
Question
My concrete question is how to expose the container to the outside world and I can connection my container to the other remote services like a remote SQL Server?
Should I use host network or bridge with the IP forwarding?
Any help? Thanks
I changed the connection string to this :
"ConnectionString": "Server=xx.xxx.xx.xx\\MSSQLSERVER,1433;Initial Catalog=Dbname;User Id=username;Password=xxxxxxx;"
then i restarted the AppPoll and it worked
What is the current network you're using for this container? If you used the default network, then you're using Network Address Translation (NAT). What that means is that you're using the host IP address to connect to the external network. So, your problem most likely is that the SQL Server is rejecting the connection from the IP of the container host.
The alternative on Windows is to use a different network drive. There are many options and I'd recommend you look at the option that better suits your needs: https://cda.ms/4nP
I had the same error, try removing the port from the connection string as follows:
"ConnectionString": "Server=ContainerName;Initial Catalog=Dbname;User Id=username;Password=xxxxxxx;"

Azerothcore connecting to internet via Docker

I have Azerothcore fresh installed using install with Docker method.
I am able to connect over local network using SET realmlist 192.168.1.242
What is the best method to get docker or server to allow a friend to access over the internet? Do I have to follow a different install method? Wiki isn't very clear on this.
Modify the address column of the realmlist table inside your acore_auth database and put there your public IP address.
Be aware that if you don't have a static IP address, then that value will frequently change. Also, you need to open the ports 3724 and 8085 of your router.
If you can't open your router ports, you can try using some VPN like hamachi (in that case, your public address should be your hamachi one and your friends need to be in the same hamachi room of yours). This solves also the dynamic IP issue.

Can't connect remotely to my Neo4j database

I have a Neo4j database on my desktop computer that I would like to access remotely. I'm not very knowledgeable about servers/networking, but here's a list of things I've done to try to get it working:
Uncommented the dbms.connectors.default_listen_address=0.0.0.0 line in the settings, as well as dbms.connector.http.listen_address=:7474 and dbms.connector.https.listen_address=:7473
Set up a TCP/UDP port forward on my router mapping 30408 to 7473.
Reserved a static IP for my desktop (the same one that appears in the port forward).
Defined incoming firewall exceptions on my desktop for ports 7474, 7473, and 30408 for both TCP and UDP (I'm guessing the 30408 one doesn't matter, but I've been trying everything).
When I try to connect through Chrome with {public_ip}:30408, it gives ERR_EMPTY_RESPONSE (Firefox just says "The connection was reset").
I am able to successfully connect to the neo4j browser on my local network with {local_ip}:7474.
Edit: Should I look into trying to do this with SSH? I still don't know what is going wrong in the first place.

Remote connection to Neo4j server

I believe the way to creating a remote connection is by changing this line in conf/neo4j-server.properties, specifically by removing the comment and restarting the server.
org.neo4j.server.webserver.address=0.0.0.0
My URL is https://0.0.0.0:7473/browser/ and works on the local machine, but when I test the URL in Safari on iPhone over 3G, it cannot connect.
What do I set the address to in the properties file?
I thought it was the IP address of my computer, but after trying the remote address which I got from Googling “ip address mac” that didn’t work, nor did (obviously) the local IP address of my machine, 192.168.0.14
I should point out that setting it to the IP address from Google throws an error and the log reads:
2015-01-29 17:10:08.888+0000 INFO [API] Failed to start Neo Server on port [7474], reason [MultiException[java.net.BindException: Can't assign requested address, java.net.BindException: Can't assign requested address]]
With default configuration Neo4j only accepts local connections
In neo4j-community-3.1.0 edit conf/neo4j.conf file and uncomment the following to accept non-local connections
dbms.connectors.default_listen_address=0.0.0.0
By setting
org.neo4j.server.webserver.address=0.0.0.0
enables Neo4j on all network interfaces.
The remainder of that reply is not Neo4j related at all - it's regular networking. Double check if port 7473 (and/or 7474) are not blocked neither be a locally running firewall nor by your router. You local IP 192.168.0.14 indicates you're behind a router doing NAT. Therefore you have to setup a port forwarding in your router for the ports mentioned above.
Please be aware that this is potentially dangerous since everyone knowing your external IP can access your Neo4j instance. Consider using either https://github.com/neo4j-contrib/authentication-extension or use a VPN in favour of port forwarding.
in 3.0:
##### To have HTTP accept non-local connections, uncomment this line
dbms.connector.http.address=0.0.0.0:7474
Confused myself with the setting. Anyone who has the same problem, 0.0.0.0 just means “this server isn’t local any more” and so to access it you use the public IP address of the computer that’s hosting the Neo4j server.
Just make sure that the ports you set in the server properties (default are 7474 and 7473) are open for incoming connections on your router/firewall etc.
I think there's some confusion here. That configuration property org.neo4j.server.webserver.address is about which IP address the server you're starting listens on for external connections. Relevant documentation is here.
It seems you're asking how to configure your database to talk to a remote database. I don't think you can do that. Rather, by editing that file you're planning on running a database on the host where that file is. Your local database on that host will write files to wherever the org.neo4j.server.database.location configuration parameter points.
A remote connection is something that the neo4j shell might establish, or that you browser might make to a foreign server running neo4j; but you don't establish that sort of remote connection by editing that file. Hopefully this helps.
Also if you have ssh access to remote server with neo4j you can setup ssh tunnel to access it via localhost:
ssh -NfL localhost:7474:localhost:7474 -L localhost:7687:localhost:7687 yourname#yourhost
then type in browser:
localhost:7474
Depends on the version.
Look for the phrase 'non-local connections' in the conf file.(In my case, $NEO4J_HOME/conf/neo4j.conf)
Then follow the instructions in the comments.
In my case,
# With default configuration Neo4j only accepts local connections.
# To accept non-local connections, uncomment this line:
server.default_listen_address=0.0.0.0

Cassandra Cluster Setup getting JMX error

I m trying setup a cassandra cluster as a test bed but gave the JMX remote connection error. I seem to found the answer for my error from cassandra FAQ page
Nodetool says "Connection refused to host: 127.0.1.1" for any remote host. What gives?
Nodetool relies on JMX, which in turn relies on RMI, which in turn sets up it's own listeners and connectors as needed on each end of the exchange. Normally all of this happens behind the scenes transparently, but incorrect name resolution for either the host connecting, or the one being connected to, can result in crossed wires and confusing exceptions.
If you are not using DNS, then make sure that your /etc/hosts files are accurate on both ends. If that fails try passing the -Djava.rmi.server.hostname=$IP option to the JVM at startup (where $IP is the address of the interface you can reach from the remote machine).
But can somebody help me on how to do -Djava.rmi.server.hostname=$IP
Or what to add is hosts file, i know that in hosts normally we add "IP Alias", but whose ip and alias.
I dont know much java or either linux
I m currently working on ubuntu v10.04 and cassandra v0.74
Sudesh
For JMX you need to enable JMX-remoting:
java -Dcom.sun.management.jmxremote
Depending on from where you want to access the jmx-server, you also need to specify a port:
-Dcom.sun.management.jmxremote.port=12345
and set or disable passwords.
Have a look at http://download.oracle.com/javase/1.5.0/docs/guide/management/agent.html for more details.

Resources