Port forwarding on iPhone?

I'm using iPhone as a modem.

Is there a way to port forward to my computer because I'm using it as a development server.


Solution 1:

Short answer

Until now (iOS 9.1) there has been no way to configure port forwarding in Personal Hotspot

Long Answer

Activating Personal Hotspot on an iOS device enables it's built-in NAT router. Other devices that connect to this iPhone (using USB, WiFi or Bluetooth) get an IP in the 172.16.0.0/12 subdomain.

There are no NAT settings in iOS, nor does it provide UPnP or NAT-PMP for remote NAT configuration.

Why?

Nobody knows Apple's reasons.

Wild guess: Knowing that availability of the Personal Hotspot feature on an iOS device depends on it's carrier, Apple may have disabled further features as way to play nice with the carriers.

Possible Workarounds

  • On the device that needs to accept incoming connections: connect to a VPN that provides a public IP and incoming connections
  • If you have access to the remote device you could create a tunnel (e.g. with ssh)
  • If the remote device is connected to the same iCloud account, enabling Back to my Mac will put you on the same private IPv6 network
  • Using a 4G modem instead of your iPhone will give you a direct internet connection accepting incoming connections

Edit: BUT...

Even you could bypass NAT on your device, your cellular IPv4 internet connection is very probably also behind a carrier-grade NAT.