Use UPnP to map ports on the vro

Source: Internet
Author: User

Abstract:
Use the UPnP method to map ports on the TP-link and use the WCF timed transmission of dynamic Dialing IP addresses for remote access and management.

Requirements:
When a customer uses dial-up Internet access, the IP address changes frequently. When a system is just deployed, it often needs to be connected to the update program and database. It is inconvenient to call a's total QQ remote connection every time,
Of course, it is most convenient to directly establish port ing on the vro, but a is always the General Manager of Enterprise, enterprise A's network management system is in conflict with the new system (because everyone understands it ),
Therefore, we can only find another way. Fortunately, we found that the company's http: // 192.168.1.1 can be accessed, and it is the legendary TP-link. Of course, the password cannot be obtained.

Process:

First think of an article about mgen brother (http://www.cnblogs.com/mgen/archive/2013/02/03/2890987.html)
After downloading the code, run the message upnpnat. staticportmappingcollection; this reference is empty. The test found that the UPnP of the XP system is not enabled, so I started the information.
The result shows that no components are installed at all. When components are installed, no discs are found-all of them are in ghostversion. During the past few years, XP was installed on disks.
In the tangle, I thought, why do I need to install components on the computer for port ing on your vro? So I realized port ing in Google C # UPnP and found 2 documents, it is found that to add a ing on a vro, you only need to call the IPC interface of the vro. The Calling is based on HTTP soap. At this point, you do not need to find the XP installation disk, unfortunately, the code downloaded from the two documents cannot be passed.
However, the idea is that you can log on to your own vro and open the UPnP menu. We find that PPLIVE has mapped 4 records magically, disabled UPnP, and opened UPnP again later, I found that PPLIVE can always add a tcp udp ing ^ _ ^ after I enable UPnP again. It's easy here.

Open your HTTP analyzer and follow the trace. soapaction:... addprotmapping is displayed in front of you. Then open vs2010 and write down

            WebClient wc=new WebClient();            wc.Headers.Add("User-Agent", "OS/version, UPnP/1.0, MiniUPnPc/version");            wc.Headers.Add("SOAPAction", @"""urn:schemas-upnp-org:service:WANIPConnection:1#AddPortMapping""");            wc.Headers.Add("Content-Type", "text/xml");            var url=string.Format("http://192.168.1.1:1900/ipc",firewallAddress);            byte[] data=Encoding.Default.GetBytes(xml);            wc.UploadData(url, "POST", data);            MessageBox.Show("zhong bu zhong ???")

 

After the execution is complete, refresh the UPnP list in the vro. a tcp ing from the local port 3389 to the Internet port 26691 is successfully added .....
Program:

The port problem is solved, and the next step is to use WCF to dynamically send the IP address obtained by dialing. This is relatively simple. I have my own website, rented space, and put a WCF Service Page on it, after installing a applet on the client's computer, you can obtain the customer's public IP Address by sending a timed request to the specified page.

Public String regip (string clientno)
{
VaR properties = operationcontext. Current. incomingmessageproperties;
VaR endpoint = properties [remoteendpointmessageproperty. Name] As remoteendpointmessageproperty;
VaR IP = endpoint. address;
..................
To download some of the WCF code, go to http://www.cnblogs.com/wdfrog/archive/2013/04/12/3016184.html
The code of the above port ing program needs to leave an email, and send a uniform ^_^ at home!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.