I have an HTTP service bound to port 8000 that I want to access from another computing on the network, but I can't seem to connect using the external IP address of the machine (e.g. 192.168.0.105). I've checked the OS X firewall isn't running, so I'm assuming the issue is the service is only bound to the IP address 127.0.0.1, and not the external IP address.

What would be the easiest way to temporarily forward external connections on port 8000 to 127.0.0.1:8000?

link|improve this question
feedback

4 Answers

Use ipfw, it likes iptables in linux.

I guess you are using ssh port forwarding a service to your local.

ipfw add fwd 127.0.0.1,8000 tcp from any to 192.168.0.105 dst-port 8000

The other machine on the network is able to access the service via 192.168.0.105:8000

link|improve this answer
Also, check that both "sysctl -n net.inet.ip.fw.enable" and "sysctl -n net.inet.ip.forwarding" are enabled (set to 1). This should be the way to do it, however it seems broken in Mac OS 10.7 – Claudio Floreani Apr 16 at 22:39
feedback

If I understand correctly, Squid might work. Also, try the computer name rather than IP, or some other service (ping, VNC, FTP, etc)

link|improve this answer
feedback

First, make sure you're going after the right problem. You can check what IPs the web server is listening on with the netstat command:

$ netstat -an | grep LISTEN
tcp46      0      0  *.8000                 *.*                    LISTEN
tcp4       0      0  *.88                   *.*                    LISTEN
tcp6       0      0  *.88                   *.*                    LISTEN
tcp4       0      0  127.0.0.1.631          *.*                    LISTEN
tcp6       0      0  ::1.631                *.*                    LISTEN

In the first line of this example, the "*.8000" means that something (presumably the web server) is listening on port 8000 on all bound IPs. On the other hand, the last two lines mean something is listening on port 631 on the IPv4 and IPv6 loopbacks (127.0.0.1 and ::). If you see "127.0.0.1:8000" when you run the command, that means you're on the right track in your diagnosis.

If this is the problem, it's probably best to solve it by getting the web server bound to all IPs, rather than trying to work around it with a forwarder. Check your Apache config file(s) (the default on OS X is /etc/apache2/httpd.conf, plus everything "Include"ed from it) for "Listen" directives. If you see

Listen 127.0.0.1:8000

change it to

Listen 8000
link|improve this answer
feedback

easiest and quickest way to make locally bound ports available to the public interface without reconfiguring the underlying service is to create a ssh port forwarding and make it available globally (by default it only listens locally)

Because it's the same machine, you will have to use different ports. On the Mac where the service runs, start

ssh -v -g -L 8001:localhost:8000 localhost

-v for verbose, so you see the incoming connections

-g to make it available on the public interface

-L port:targethost:targetport well, you know that already :-)

in case you have more than one active interface on the machine, extend the -L statement to include the adress you want to bind it to.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.