I have a PC and a 2011 Mac mini on one wireless network, which does not have Internet access. The Mac mini is also connected to another network which has Internet access.

Is there a way I can share access to a single IP using the Mac? i.e., Forward all requests on ports XX-YY to AAA.BBB.CCC.DDD?

EDIT: I'd prefer a solution that is 100% command-line based.

OS X 10.11.3
I need the PC to be able to access resources on the Mac's network.
Internet sharing replaces the Mac's connection to the wifi network.

The PC is wired to a wireless router without internet. The Mac is wired to a wireless router with internet. The Mac is also wifi connected to the PC's wireless router. The PC's wireless router is not capable of acting as a client.

  • I flagged your question as unclear. If you have two different wi-fi networks (one with and the other without internet access) you may simply connect the PC to the wi-fi with access to the internet. If you have one wi-fi network (with internet) and one ethernet network, internet sharing (set up properly) doesn't break the wi-fi network (=internet). Please specify your network environment.
    – klanomath
    Commented Feb 29, 2016 at 2:46
  • If each of the two machines are really attached to their respective wireless router with an ethernet cable then Dictionarics Anonymous' should work. You have to disable any DHCP server on the routers though. Additionally the router attached to the PC has to be capable of working as a switch/bridge.
    – klanomath
    Commented Feb 29, 2016 at 22:23
  • It's a crappy AT&T router. It doesn't bridge wifi to ethernet like nice routers can.
    – Daniel
    Commented Feb 29, 2016 at 23:59
  • But given the fact that in a slightly different (and achievable) situation his answer would work, I'll accept it.
    – Daniel
    Commented Feb 29, 2016 at 23:59
  • Please un-accept my answer so that I can delete it. Commented Mar 21, 2016 at 19:37

2 Answers 2


An SSH tunnel will serve the purpose here, assuming that you configure a gazillion LocalForward ports.

Place these contents into your ~/.ssh/config file:

Host [hostname]
User [username]
Port [SSH port]              # (if using port 22, omit this line)
LocalForward 1     # Replace all these
LocalForward 2     # port numbers with
LocalForward 3     # the actual ports
LocalForward 4     # that you need.
LocalForward 5     #
LocalForward 6     # Format is like this:
LocalForward 7     # LocalForward [port][port]
LocalForward 8     #
LocalForward 9
LocalForward 10

... and so on for whatever ports you want.

This will set up listening ports on the Mac, and will forward the traffic on those ports to [hostname] over an SSH connection to [username] on port [SSH port] whenever you run this Terminal command:

ssh [hostname]

Keep in mind that [hostname] must be running an SSH server, and you will get a shell on the remote host in Terminal. It's possible to configure a port-forward-only SSH server, but that is beyond the scope of this answer. If you don't want a shell on the remote server, run this command instead:

ssh [hostname] sleep 3600

You will instead get a 1 hour connection, and no shell. Don't close the Terminal window. If you want, you can set it up such that you can close Terminal by running this:

nohup ssh [hostname] sleep 3600 &

Replace 3600 with the number of seconds you want the connection to last.


NOTE: Turns out I was mistaken in what the question was asking. It was internet sharing that @Daniel wanted, not port forwarding. My mistake. I'm leaving this answer here for the sake of informing about port forwarding, but this isn't the best solution for how to solve this problem.

Sure! You're trying to accomplish port forwarding, which a variety of programs can do. If you like using Apple software with a nice GUI, OS X Sever works fine. @klanomath has told me that "OS X Server neither allows port forwarding nor NAT/Routing. Not allowing neither of both it doesn't provide a GUI", so I've removed this suggestion.

ipfw used to be the default for port forwarding. However, it's since been deprecated for pfctl. I personally am very dumb and don't really know what's happening when you use it. I'll paste the (heavily summarized) contents of a GitHub instruction thing. Create an anchor file under /etc/pf.anchors/<anchor file> with your redirection rule like: rdr pass on lo0 inet proto tcp from any to ABC.ABC.ABC.AB port AB-AB -> AAA.BBB.CCC.DD port XX-YY. To my knowledge, I don't know of any nice GUI clients.

SSH also supports tunneling. For you, you'll probably want to use the command ssh -D AAA.BBB.CCC.DD:XX-YY. There's also a variety of clients that you can use to make managing this a bit easier than via the command line.

You can also configure it at the level of your router. Obviously this depends on your router, but portforward.com has instructions for lots of routers (as does Google.) For example, you can use AirPort Utility to configure port forwarding.

But don't be restricted! Look around, there's tons upon tons of software and methods of doing this.

  • I'm using OS X, and can't change that. Just plain ole OS X.
    – Daniel
    Commented Feb 29, 2016 at 1:31
  • @kanomath Can edit! Will do shortly.
    – JMY1000
    Commented Feb 29, 2016 at 15:26
  • @klanomath Okay, I've edited it to hopefully include more content. I'm not sure what you have against OS X server (besides it being paid), but I've omitted it anyways.
    – JMY1000
    Commented Feb 29, 2016 at 17:58
  • @Daniel I've edited it to hopefully include more content, let me know if this helps you.
    – JMY1000
    Commented Feb 29, 2016 at 17:59
  • Still not helpful...
    – Daniel
    Commented Feb 29, 2016 at 20:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .