How do I reach a ddev site from LAN with docker-ce in an WSL2 enviroment? - wsl-2

When configuring ddev with a project TLD it becomes unreachable when replacing "docker desktop" with "docker-ce".
project_tld: testing
How can I reach the project again from my local machine and from our company LAN?

The reason for the website becoming unreachable is that WSL2 only binds ports to the localhost and not to every interface.
Docker desktop itself binds to every interface and forwards everything to WSL2 that is why it worked. For docker-ce a manual solution is required.
The problem is documented in the wsl documentation and a solution is described.
A script for discovering and setting the port forwarding automatically is found in an older WSL2 issue on github.
With the localhostForwarding option set (documentation) for WSL2 the following commands work too:
netsh interface portproxy add v4tov4 listenport=80 connectport=80 connectaddress=127.0.0.1
netsh interface portproxy add v4tov4 listenport=443 connectport=443 connectaddress=127.0.0.1
In some future version Microsoft may bring the bridged networking option back for WSL2 see issue discussion.
Edit: After moving from Docker Desktop to docker-ce I have discovered that my solution doesn't work as it prevents wsl from listening to the 127.0.0.1:80/443 after a restart. The powershell solution in the fourth link works as it directly connects to the wsl ip adress.

Related

Can't connect to documentdb emulator in virtualbox

I am trying to setup a DocumentDB emulator on my Win7 local, then found out it only supports Windows 10.
then I installed the emulator on Windows10 VirtualBox, I have no problem seeing the Emulator page using localhost.
however, when I try to connect from my Win7 local box to the emulator on Win10 virtualbox, I can't get a connection (either from browser pointing to https://localhost:8081/... or from code).
Is the DocumentDB Emulator only accessible from the machine running it?
i turned off windows firewall on Win10
I ran Emulator on port 443 on Win10
Virtualbox network config: NAT Port forwarding 8081 to 443 (i have similar config for SSH from Win7 to Linux VB that works)
thanks in advance
I had the same problem, this is how I succeeded.
First, install DocumentDBEmulatorCertificate from your VM to the host, as a trusted certificate. Here you can find how to export it.
Then forward a port to 8081 with netsh:
netsh interface portproxy add v4tov4 listenport=64000 connectport=8081 connectaddress=127.0.0.1

Cannot access eclipse orion server from local machine using local IP

I have been given a centos server to lauch eclipse orion code editor. I installed eclipse orion as per the instruction on https://wiki.eclipse.org/Orion/How_Tos/Install_Orion_on_Localhost (steps for linux using jetty server). It works fine on centos browser. The centos os is running on 198.168.1.226. So that I can access the following urls on web browser of centos.
198.168.1.226:8080
localhost:8080
127.0.0.1:8080
0.0.0.0:8080
But when I tried to access the 198.168.1.226:8080 from other local machines on local network, that is not accessible. I searched the StackOverflow Questions like how to make jetty server accessible from LAN? and Unable to access jetty server with local IP address but both are useless for me. How can I fix this situation? Can I fix it editing the code on orion.ini file or need to deal with configuration file or something else?
I have also tried the orion for windows computer but it worked itself for accessing the orion system for any other computer in local network. But I am surprised to face it on centos using the jetty server for setting up eclipse-orion system .
First of all check that have you allowed specific port (8080) from eclispse.
add rule with that port no. in centos iptables as below:-
iptables -A INPUT -p tcp --dport 8080 (adjust according your port no.) -j ACCEPT

How can I open some ports on Ubuntu?

I know a little about Linux. Today I created a VPN server on my Ubuntu installation according to Set up a simple IPsec/L2TP VPN server for Ubuntu, Arch Linux and Debian.
But when I finish the installation, I use my iPhone to connect the IPsec VPN, bur it shows the VPN Server has no response.
The GitHub document shows
Ports 1701, 500 and 4500 must be opened for the VPN to work!
So I have tried to open these ports on my Ubuntu server.
I use the iptables command to open these ports, but it failed. Maybe I don't known how to use this command correctly. How can I open these ports on my Ubuntu server?
And if these ports have been opened successfully, can it be proved by the Windows CMD window through telnet'ting the port?
Ubuntu these days comes with UFW - Uncomplicated Firewall. UFW is an easy-to-use method of handling iptables rules.
Try using this command to allow a port:
sudo ufw allow 1701
To test connectivity, you could try shutting down the VPN software (freeing up the ports) and using netcat to listen, like this:
nc -l 1701
Then use telnet from your Windows host and see what shows up on your Ubuntu terminal. This can be repeated for each port you'd like to test.
If you want to open it for a range and for a protocol
ufw allow 11200:11299/tcp
ufw allow 11200:11299/udp

Can't access tomcat web page from lan

I installed a tomcat7 server on a ubuntu 12.04 box. I simply used "apt-get install tomcat7". I did not install apache2. I can access the default page from localhost:8080, 127.0.0.1:8080, and 192.168.1.201:8080, where the latter is the IP address from my LAN. my end goal is to be able to access the web server from outside the LAN with port forwarding. For now, however, I can't even access it inside the LAN.
Problem:
I can't access the web page from any other computer (windows 7, iPad) on the same LAN! I
get the "connection has timed out" error from the browser.
Question: Can I run tomcat on it's own without installing Apache2 first? This is the current setup and I can access pages hosted on tomcat on the same server, but not over the LAN.
Other information:
I can ping the ubuntu computer from other machines
The ubuntu firewall is disabled (checked via the firewall GUI interface).
I also tried "sudo ufw disable"
I tried: "sudo service iptables stop" and got the message: "iptables: unrecognized service"
I also tried disabling the appArmor firewall:
sudo /etc/init.d/apparmor stop
sudo /etc/init.d/apparmor teardown
sudo update-rc.d -f apparmor remove
I set the router firewall policy to minimum: inbound: accept all; outbount: accept all.
All computers (including ubuntu server) are connected to LAN via wireless
The ubuntu server IP address is static, not DHCP
I checked the SELinux folder and it's empty. I removed it.
Thank you for your help,
Omar
EDIT:
I can connect from within the LAN using ssh (I installed OpenSSH on ubuntu).
ANSWER:
I found the solution to this problem. It turned out there was a firewall active that was blocking the port. The firewall is called "firestarter". Not sure how this was installed, but it can be downloaded from the ubuntu software center. The default inboud policy blocks all ports except for SSH (22). I opened port 8080 and everything worked just fine. The other firewalls (ufw and SELinux) were disabled.
Thank you all again for your help.
Omar
First of all make sure all of the IP addresses are topologically correct, then ping to the your apache server system, If all this succeeds your network is fine.
Now the question are you using the Ubuntu Server edition? if this is the case i believe you can setup apache out of the box.
In case of the Desktop edition you could install it using command line or just install something like XAMP from apache friends.
Make sure your apache Server is started
If you do not already have Apache installed, you can do so now by issuing the following commands:
sudo apt-get update
sudo apt-get install apache2
This is all that is necessary to have a working web server.
I think, "apt-get install tomcat7" doesnt works in Ubuntu. You have to manually download the TAR file & then you can install it with the scripts. Please check whether it is properly installed or not. it should show a Apache Tomcat Homepage # localhost:8080
Also if it is installed properly, check whether it is running on the port 8080, or any other port.
If everything is fine, then disable the firewall of the Server, where you have installed the Tomcat. check for the server IP.
Now from other machine, access that server using http://server_ip:port
This should work fine. No issues should be there.
The other thing, you have metioned in your question, UBUNTU BOX. May be this issue arises due to UBUNTU BOX. If possible, make a clean install of Ubuntu.

Connect to PostgreSql database in Linux VirtualBox from Win7

As said in headline, from Win7 host I'm trying to access Postgres 9.3 established in Linux Centos 5.8 which is in VirtualBox on the same machine. I'm trying to access it from PGAdmin and everything is OK when I start the Postgre from Win7 services, so PGAdmin is well configured.
What have I tried? I've read many articles about this subject, and even some questions on this forum but nothing worked. I have:
switched to NAT and forwarded port 5432 in VirtualBox GUI
set listenadresses = '*' in postgresql.conf file
put host all all 10.0.2.1/24 md5 line in the pg_hba.conf file
put 5432 port inbound and outbound rule in win7 firewall settings
disabled linux firewall with #service iptables stop
Just to mention. When service is started in virtual linux, I can access it from linux, so service is properly started. Problem is that windows doesn't see that service. And when service is started from linux, I can start the same service in Win and vice-versa although the port 5432 should be occupied.
The most suspicious part to me is point 3) because I'm not sure whether i have put good address in rule. That address vary from article to article, and I would appreciate if someone could explain me how to be sure which address (or range) to put there, according to my network. Or some other advice if possible. Thanks.
Solved.
Replacing:
"host all all 10.0.2.1/24 md5" with "host all all 0.0.0.0/0 trust" solved it.
In my case adding the below line to pg_hba.conf was enough:
host all all 10.0.0.0/16 md5
and then restart:
sudo /etc/init.d/postgresql restart
The Solution by Filip works, but you can tailor it further.
First, enable Adapter 2 in VM and set it to Host-only Adapter:
Second go to your host machine and find it's ip address.
This can be found by running ipconfig in your windows host machine.
Now you need to edit two files in your VMBox.
First is postgresql.conf
sudo nano /etc/postgresql/<version>/main/postgresql.conf
and add the following line:
listen_addresses = '*'
save it and then edit pg_hba.conf
sudo nano /etc/postgresql/<version>/main/pg_hba.conf
Here you need to add your host machine ip (in my case it was 192.168.56.1:
host all all 192.168.56.1/0 trust
Save it and restart postgresql
sudo /etc/init.d/postgresql restart
Now you can use pgadmin to connect to vm postgresql.
Convenience!

Resources