Docker container not using NordLayer VPN while connecting to internet - docker

I want my local docker container to connect to my MongoDB Atlas. But it seems like when I connect to NordLayer VPN, the container is not taking Nord's static IP which we have reserved and whitelisted on Atlas.
If I do "curl https://ipinfo.io/ip" from the container, it shows some random public IP, and if I do "What is my IP?" on google then it shows the Nord's static IP, which suggests that the container is not using VPN to go over the internet but regular browsing uses VPN IP.
I have read and implemented many posts but nothing as of now has worked for me.
Version: Ubuntu 20.04.3 LTS
I get below error when I am attempting to connect:
Connection Error: MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/
FYI:- The same setup works on Mac

The issue is resolved after changing the Nordlayer protocol tp OpenVPN UDP
$ nordlayer settings set
Select setting to change:
1: VPN Protocol
2: Auto-connect
3: Always connect to
4: ThreatBlock
Select [number]: 1
Available values for VPN Protocol
1: Automatic
2: IKEv2/IPSec
3: OpenVPN TCP
4: OpenVPN UDP
Select [number]: 4

Related

How can I run docker behind the GRE Tunnel?

So I am having a pterodactyl installation on my node,
I am aware that pterodactyl runs using docker so to protect my Backend IP from being exposed when connecting to the servers I am using a GRE Tunnel from X4B.net
After installing the script I was provided by X4B I got this message
Also Note: This script does not adjust the configuration of your applications. You should ensure your applications are bound to 0.0.0.0 or the appropriate tunnel IP.
At first I was confused and tried connecting to my server but nothing worked, so I was thinking that it was due the docker not being bounded to 0.0.0.0
As for the network layout I was provided with:
10.16.1.200/30 Network,
10.16.1.201 Unified Gateway,
10.16.1.202 Bound via NAT to 103.249.70.63,
10.16.1.203 Broadcast
So If I host a minecraft server what IP address would I use?

How to set up subdomains with traefik and docker in a local network?

I have a raspberry pi plugged into my home router, running Ubuntu 20.04 and Docker.
I gave it a fixed ip and its hostname in the local network is raspy.local. I can access docker containers via raspy.local:<portnumber>.
What I would like to do is to have docker containers be reachable via subdomains, like influxdb.raspy.local or traefik.raspy.local etc. The only solution that worked was to run traefik as a docker container, set Host(`<subdomain>.raspy.local`) rules and edit the /etc/hosts file on my laptop so that the subdomains point to the IP address of the raspberry pi.
This is a bad solution because I have to edit the /etc/hosts file every time I make a change and anyways this cannot be done on all the devices on my network (e.g. I cannot to it on smartphones).
What is the proper way to do it?
(I have found other similar questions here on SO, but I didn't find one with information on how to do this within a local network)
You need to setup a local DNS server:
Set a static IP on your RPi and install PiHole in it.
Set an A record for each of the subdomains you want in the PiHole DNS configuration, pointing to the IP of the device running Traefik (same RPi in your case) (eg: A subdomain.raspy.local -> 192.168.0.xxx)
Set your main router DNS IP Address to the address of your PiHole Server.
Now every device connected to the router is going to be able to reach the Traefik server using domain names.
#30daysofstackoverflow

App Engine PostgreSQL connection error using TCP

I have a Python 3 application deployed in Google App Engine, flexible environment.
I'm using psycopg2 to connect to a PostgreSQL instance hosted in Google cloud SQL.
I'm having trouble connecting to PostgreSQL from Google App Engine.
Cloud SQL Proxy seems to initialize ok, but it binds to 0.0.0.0
Listening on 0.0.0.0:5432 for projectID:us-central1:my-db
Trying to connect on 127.0.0.1 or localhost doesn't work. Connection is refused.
What does work is using the docker (app engine flexible environment uses docker underneath) default IP 172.17.0.1 (from the docker0 adapter)
Using that IP address to connect to Cloud SQL seems like it would bite me in the ass if someone decides to change it.
Why is this happening?
Is using the default docker0 adapter's IP address a viable long term solution?
Is there an alternative other than switching to a socket based connection instead of the tcp approach.
It sounds like you are running the Cloud SQL proxy on your host machine, while you are attempting to run your application from inside a container. The reason it can't connect to the proxy is because 127.0.0.1 refers to docker's loopback interface, while the proxy is bound to the host machine's interface. The 172.17.0.1 is the address the container can use to can reach the host interface.
One alternative is to use host networking (https://docs.docker.com/network/host/), by passing in --network host. This will cause the host's interface to be used for the application.
I've switched from using TCP as the connection method and to using a Unix Socket.
The TCP issue seems to be a bug in the app engine flexible environment. But it's a beta feature (it is under the name beta_settings in app.yaml) and I'm not holding out for Google to fix it.
I also don't want to commit to an IP address that could be changed sometime in the future as a workaround.

How do I setup a docker container that I can connect to from any computer on my local network?

I'm trying to create a Docker container that I can connect to from any device on my local network. Specifically, this container: https://hub.docker.com/r/codercom/code-server. I've tried using Docker Desktop and Docker Toolbox but I've only been able to get it working on my host device. How do I configure my network or other settings to allow other devices on my local network to connect to the container?
I've tried following similar stackoverflow questions, docker forums, and youtube videos. I've tried setting of bridged network connections but nothing has worked for me.
These are some of the sites that I've been on and tried to replicate the solution to my similar problem.
https://forums.docker.com/t/bridge-with-docker-for-windows/30936
https://stackoverflow.com/questions/39111247/how-to-access-docker-container-from-another-machine-on-local-network
https://blog.oddbit.com/post/2014-08-11-four-ways-to-connect-a-docker/
Edit1: The command that I run is: docker run -it -p 127.0.0.3:8443:8443 -v "${PWD}:/home/coder/project" codercom/code-server --allow-http --no-auth This part works but when I try to access 127.0.0.3:8443 from a different computer on the same network it doesn't work. I've tried to solutions from the links that I posted above but I get the same result where the address that I put in fails to load.
What I want to do is host code-server from my desktop computer and allow for a device like a laptop to connect to the code-server. I'm currently on a windows 10 pro machine. Can anyone lead me into the right sort of direction?
Solution:
When I installed Docker for Windows, it creates a network called vEthernet (DockerNAT) (Usually with the IP 10.0.75.1)
My local machine had a network called local area connection with the IP 192.168.0.172(With this IP I was trying to access from other PCs).
So far, My local Machine had Two networks Connections so that I went to Control panel > NetWork and Sharing center > Change Adapter Settings I selected the two networks and I right-click selected Add to bridge. That creates a Third network called Ethernet.
At this point, I didn't know what was the Ip of Ethernet network, so I executed ipconfig command that shows me the IP 192.168.0.17(The settings of local area connection and vEthernet (DockerNAT) disappeared and the IP's 10.0.75.1 and 192.168.0.172 stop working).
With this new IP (192.168.0.17) I tried from another machine in the network and finally I could access to the container(192.168.0.17:9090).
Important if you have a firewall enabled then you need to execute the below script in PowerShell
if (!(Get-NetFirewallRule | where {$_.Name -eq “gitlab 9090”})) { New-NetFirewallRule -Name “gitlab 9090” -DisplayName “gitlab 9090” -Protocol tcp -LocalPort 9090 -Action Allow -Enabled True}
Replace the gitlab and port 9090 with your image name and port.

Accessing lamp container over lan using Kitematic

I have a basic Lamp container installed and running using Kitematic. I want to access the url over lan for testing purpose.
Enabling bridged networking on the dev VM should allow you to do this, though it requires take a few steps for now. Make sure you understand the security implications of allowing all other machines on the network to contact the VM.
Add a third network adapter in the VM settings pane. For Name, choose the adapter or network on which you want your VM to be accessible.
To get the the IP of the VM, type the following on CLI:
docker-machine ssh dev
ifconfig
And look for the IP with the same subnet as other machines on the network. E.g. 192.168.0.x
Open the web preview as usual in Kitematic.
Lastly, replace the IP in the browser bar with the one found in step 3.
This should be accessible to other machines on the network.

Resources