I cannot get Port Forwarding to work (wip_ipFwdEntryAdd) and I wondered if anyone out there has managed to use it successfully.
Using (basically) Internet gateway code on my unit, I can successfully get a laptop to connect to the web i.e. a LAN to WAN connection using the NAT functionality in the code. I tried this with the DHCP turned ON and also OFF in the code. My SIM is one with a public, static IP address and can be externally accessed (as if it was a server). I added the port forwarding code using the wip_ipFwdEntryAdd function, creating a route between the WAN and the LAN, but it does not appear to work. I have tools to monitor the IP address and ports on both the WAN and LAN sides, and I get no data at the LAN end when sending data to the WAN end.
Can anyone please help? Has anyone used this function?
Just to give you an update in case anyone else has this problem…
I got it working OK. The problem was that, for the public IP in the port forwarding entry, I was using the public IP address instead of using the SIM’s IP address. The SIM’s IP address is the one on the private side of the provider’s APN.
Can you elaborate a little bit more what you have done?
How did you get the “public IP address” ( WIP_BOPT_IP_ADDR ? ), and how did you get the “SIM’S IP address”?
We obtained a SIM with a special account. The SIM has a public IP address, and a private one. Both these addresses were given to us by the service provider when we obtained the SIM. The port forwarding routine uses the private SIM address.
To make things really simple… forget what I said about public and private IP addresses, it just adds to the confusion.
The fact is that the IP address required for the port forwarding can be read from wip_bearerGetopts, and is WIP_BOPT_IP_ADDR. This is available after attaching to the GPRS bearer. Use that one.
Many thanks for your answers! Unfortunately there is no sample code about the port forwarding and there is no debug info about the port forwarding. ( only the the return value of the wip_ipFwdEntryAdd() function) It would be also useful to know how many bytes are transmitted or received on the port forwarding port.
I have a problem with port forwarding too.
I followed your instructions.
On the GPRS side I use SIM card with public IP address. On the LAN side modem is connected to the router. Ehternet interface in modem has a static IP address assigned by wip_bearerSetOpts function (WIP_BOPT_IP_ADDR).
The device is visible on the LAN network (Responds to PING request).
I set WIP_NET_OPT_IP_FORWARD flag to TRUE in wip_netInitOpts function. When connected with GPRS I set flag WIP_BOPT_EXTNAT to TRUE, to Enable the NAT for GPRS interface.
I use Wireshark to monitor packets on the WAN and LAN side. Packets pass from WAN to LAN, but on the LAN side they don’t have changed the source IP address. Source IP address is still the addres from the WAN, not the LAN modem address.
This means that packets reach the recipient on the LAN, but don’t go back to the modem. The router doesn’t know what to do with them, because sender IP addres is outside the LAN network.
I don’t know why the WAN addresses are not converted to the LAN modem IP address.