0

I have an ubuntu server that is currently connected to my iMac via Ethernet bridge with ip address 192.168.2.2. iMac is sharing the internet with ubuntu server with this.

The iMac's IP address is 192.168.0.105 in the LAN network to the main router/modem. And 192.168.2.1 on the Ethernet bridge with ubuntu server.

The ubuntu server is allowing apache to be accessed to all via port :80.

So in iMac, I ran sudo ssh -L 80:0.0.0.0:80 ubuntu@192.168.2.2 and I can access the apache server directly in my iMac browser using localhost.

Question is, if I have another computer in the LAN that I would like it to access the apache ubuntu server via iMac ip address 192.168.1.105. How would that work?

I have tried accessing it with 192.168.0.105 in the computer browser, but doesn't seem to work. And it's not possible to access it directly with 192.168.2.2 since that's the ip address over the Ethernet bridge connection to iMac.

AFwcxx
  • 125
  • 5

1 Answers1

0

Using the -L flag, you can specify what address to listen on instead of localhost, which is the default. So this command:

ssh -L 0.0.0.0:80:127.0.0.1:80 ubuntu@192.168.2.2

would bind on all interfaces on your iMac computer, and forward any queries on port 80 to 192.168.2.2 (actually, to the local interface on that computer, so your Ubuntu server will see every incoming request targeting 127.0.0.1).

This way, computers on the same network will be able to connect to your iMac, if the firewall allows it.

Lacek
  • 7,233
  • 24
  • 28
  • Thank very much @Lacek. I've never noticed that [bind_address] option before. Learned something here :) – AFwcxx Jun 25 '20 at 01:58