2017年1月6日 星期五

Port Forwarding– part 2. Solution

源自於
https://alselectro.wordpress.com/category/bluetoothwifi/


After struggling for nearly a week with MTS dongle , finally I found an excellent solution to enable PORT FORWARDING.
HUAWEI POWER FI  E8221 model dongle  is the solution I found.This dongle accepts any data SIM for internet connectivity & we can create a WIFI HOTSPOT with this dongle to connect max. of 10 devices.
Further it has got a VIRTUAL SERVER setting tab in the configuration , thus enabling Port forwarding.
There is no need of an external Router like TP-LINK (which I used with MTS , as seen in my previous post).
1
I’ve inserted a BSNL DATA SIM into the HUAWEI dongle for Internet connection.
The DEFAULT GATEWAY IP address while using Huawei is 192.168.8.1
This can also be found by opening CMD in Windows search bar & then typing the command IPCONFIG /ALL
Typing this Gateway address in the browser , you get the HUAWEI CONFIGURATION window.Here the service provider (for me BSNL ) name is displayed with connection status.
Image 1
Click on CONNECTION SETTINGS seen below the “Connected” status.
On left pane , under SECURITY tab select the VIRTUAL SERVER.
Before clicking the ADD button under VIRTUAL SERVER LIST , we’ve to configure the ESP module & start a SERVER on port 333.
Image 2
The ESP 8266 module is connected to PC through USB-TTL board & the COM port allotted in my PC is COM 48 .
I’m using PUTTY terminal software to communicate with this COM port.
Following is the screen shot on which you can see the AT commands used to connect ESP with HUAWEI on WIFI , & starting a server on port 333.
The selection of port is random.You can select any port within 65536 , except the standard ports like 80 (HTTP) ,  21 (FTP), 23 (TELNET) ,etc..
AT+CWLAP   – to list the surrounding Access Points near ESP module
AT+CWJAP=”ssid”,”password”   – to join the AP using the SSID name & its password.
AT+CIPMUX=1   — to enable Multiple connections before starting server
AT+CIPSERVER=1,333   –  to start a server on port 333
AT+CIFSR  –  displays the IP address . STAIP is the IP address we need to port forward.
Image 3
After starting the server on ESP8266 , we need to port forward under the HUAWEI configuration.
Click on the ADD button , seen under VIRTUAL SERVER LIST.
Fill in details as below :
Name  : ESP
WAN Port : 333
LAN IP   : 192.168.8.100
LAN Port  ; 333
Protocol : TCP
Status  : ON
Finally click on APPLY.
Image 4
Needless to say , you’ve to apply an INBOUND RULE on Windows Firewall settings to allow this port 333 . (check the previous post on how to do this).
The external world can contact this ESP only through the EXTERNAL IP address.To know the IP , just type in WHAT IS MY IP on Google .In my case it is 117.252.205.55
To confirm that the PORT 33 is open & listening , visit the online tool www.yougetsignal.com
You need to test this on the PC where you’ve connected the ESP module.
The external IP will be automatically displayed.You just  type in the port no. to verify.
Following screen shot shows that my port 333 is open
Image 6
Now we’re all set to contact ESP from outside World.
From a distant PC with different Internet connection , open a PUTTY terminal.
Select RAW as Connection type & type in the IP 117.252.205.55  & port no. as 333.
Following screen shot shows the PUTTY terminal which I’ve opened on a different PC with a different IP.
Image 5
On clicking OPEN button , the ESP Terminal at the other end will respond with
0,CONNECT
This means a connection established on channel 0.
Image 8
Now type in some characters on the distant PC terminal.
newip2
The ESP terminal responds with
+IPD,0,21:characters received
which indicates , it has received 21 characters on channel 0.
The screen shots with HUAWEI symbol (IP 117.252.205.55 ) is that of TERMINAL where ESP module is connected & the screen shot of distant PC is shown with the IP address 180.215.121.135
Image 9
To send characters from ESP , use the AT command :
AT+CIPSEND=0,15
This indicates that you want to send 15 characters on channel 0.
The ESP will respond with a > symbol & waits till you type 15 characters.
Image 10
The distant PC now receives the 15 characters you typed inside ESP terminal.
newip3
Hence a two communication is established with ESP Terminal & a PC from anywhere in the world.Thisopens the door for INTERNET OF THINGS where you can control the devices connected to ESP from anywhere in the World.
WATCH THIS VIDEO :
cooltext753793315    cooltext753790696
In the previous post we’ve seen the ways to control the ESP8266 WIFI module from anywhere in the world.The key to success depends on the PORT FORWARDING , where we route the contact on particular port to the local IP address of the WIFI module.
Nowadays USB dongles are used widely for internet access .This post will help you troubleshoot PORT FORWARDING.
Following is the SETUP diagram .
TPLINK ROUTER is on the top of the NETWORK. An MTS USB dongle is plugged to TPLINK Router (model TL-MR 3420 with 3G/4G support).
A Laptop is connected to TPLINK Router on Ethernet using RJ45 cable.
A USB to TTL board is connected to PC on which the ESP 8266 module is wired.
The ESP module is linked to TPLINK Router on WIFI using the AT Command AT+CWJAP=”SSID”,”password”

ip8
On switching ON the ROUTER , it assigns LOCAL IP address to the modules connected to it either on RJ45 (wired) or on WIFI.
In our set up the LAPTOP which is connected by wire is assigned 192.168.0.100
& the ESP module which is connected on WIFI is assigned 192.168.0.101.
Note that the allotment of address is on first come basis.When you power off & on the Router again , this allotment may vary.
You can RESERVE the address by selecting the DHCP tab of TPLINK configuration.Here select
Address Reservation & then feed in the MAC address of the devices you’ve connected to the Router.
To know the MAC address you can use the ADVANCED IP SCANNER TOOL.
Download & install the tool. Start the scanner to know the IP address & MAC address of the devices connected .
ip12
STEP 1:
Confirm that you’ve Internet access after plugging  the USB dongle to the TPLINK Router .You need to login the TPLINK configuration with address 192.168.0.1 & enter the QUICK SETUP for this process.
STEP 2 :
Start the SERVER on ESP module
ip2


STEP 3 :OPEN PORT SCANNER
To confirm that the port we’ve started server ( here port no. 333) is OPEN , we use a  port scanner tool .
Advanced Port Scanner is a small, fast, robust and easy-to-use port scanner for Win32 platform. It uses a multithread technique, so on fast machines you can scan ports very fast.
Also, it contains descriptions for common ports, and can perform scans on predefined port ranges.
Download it & install.
Open Port scanner & under Select port range enter 100 to 500 . As we’ve to check port 333 , we enter the range below 500 .Click on SCAN .
IP4

The PORT SCANNER displays the result regarding status of PORTs of your PC as well as the module connected to PC.
Here we can confirm that port 333 is OPEN on IP 192.168.0.101 (ESP module).

STEP 4 : SET UP FORWARDING RULE on TPLINK CONFIGURATION
On TPLINK configuration window , under FORWARDING select the tab VIRTUAL SERVERS.
Click on ADD NEW.. & enter the Service & Internal port as 333 .
IP Address as 192.168.0.101 , which is the local IP allotted by Router to ESP module.
Select Protocol as TCP & then SAVE the settings.

IP9

IP 10

STEP 5 : WINDOWS FIREWALL SETTINGS
Open Windows Firewall Advanced settings & click on INBOUND RULES.
SET the rule to allow communication on port 333.
IP11

Now you are set to check the condition of PORT 333 externally.
For this we make use of an online tool www.canyouseeme.org
On opening the site your external IP will be automatically displayed.Enter the port number to check.
Click on CHECK PORT.
ip 13
Unless you see SUCCESS on this test , you can’t contact your ESP module from external world.
If you get ERROR , open the TPLINK configuration & click on STATUS.
Note IP Address displayed under 3G/4G.
From another computer with a different internet connection try to PING this IP address.
Open CMD & type in PING x.x.x.x
ip1

If the PING result is OK , you can be sure that the ESP module can be contacted from outside world.
If the PING result is TIMED OUT , you can’t communicate with ESP.
The   STATUS tab in my case , as shown in above screen shot , indicates an IP address starting 100.86.x.x
Generally following IP address ranges are PRIVATE IP ADDRESS RANGES :
10.x.x.x
172.16.x.x
192.168.x.x
These are reserved by IANA for private Intranets & NOT ROUTABLE TO INTERNET.
Private addresses are not reachable on the Internet. Therefore, Internet traffic from a host that has a private address must either send its requests to an Application layer gateway (such as a proxy server), which has a valid public address, or have its private address translated into a valid public address by a network address translator (NAT) before it is sent on the Internet.
In my case , the MTS ISP provider hide the PUBLIC IP address.
The MTS dongle does not support VIRTUAL SERVER settings , which means PORT FORWARDING IS NOT POSSIBLE with MTS.
What I couldn’t understand was , while writing my previous blog ,it worked sometimes.While MTS customer support was contacted repeatedly , they finally accepted that port forwarding is blocked by them.
After sleepless nights I’ve found a solution….. Read on my next post ….


沒有留言:

張貼留言

Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3

  Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3 AngularJS 實例 <!DOCTYPE html> <html> <head> <meta charse...