Resolving DNS with winsock, with server behind router - c++

I recently started to play around with sockets in windows and I ran into a bit of trouble..
I have an application that I want to find a host with DNS name resolution (through an internet connection).
The program manages to resolve the DNS name to an IP address, but the IP address it finds is the one of the router that sits in front of the computer that runs the server application(which is what I expect, since it is the default gateway)..
My question would be if there is a way to connect to the server application without having to modify the router's settings by hand every time the server application is installed on a system that has a router sitting in front of it.. Or is the only way to do this to somehow forwarding the port of the computer to the router ?
Any help is appreciated!
Thnx!

If the server is behind a router, then the router has to be configured for Port Forwarding. There is no getting around that. The router needs to know which machine on its network to forward incoming client requests to for any given port. However, depending on the type of router and its features, the server app might be able to configure the Port Forwarding programmably using uPNP or SNMP, if available and enabled. Otherwise, the router has to be configured by hand by the router admin.

Related

I can access the website locally but can't access it through the internet After openning the port

I want to make my phone a Linux web server, by using the userLand application which gives you the ability to use ubuntu distribution on Andriod.
I already installed Django and ran my server on port 8080 since port 80 is busy (seems logical that android is using it)
and everything is good, it works when I try to access the website from another device on the local network.
so I proceeded to the next step which is making the website accessible from all over the internet then I found that you need to make a port forwarding on the router to allow devices from outside the local network to access a device in the localnetwork .
I followed the following steps :
made the phone's IP static locally
added the configuration needed for the port forwarding (phone's ip, port 8080, etc... )
found the public IP for my phone and used it and with port 8080
it is still not working:
I can access the website locally but can't access it through the internet.
I tried another method by using an already working server from the "AWebServer" application on google play
but still the same problem.
I tried temporarily to disable the firewall on the router but still the same problem
and finally, I tried to open the port on my laptop with OS: Windows 10
instead of the phone OS: Android, and checked with port checker but the port is closed and still the same problem.
I have been trying to solve this for a whole day)), I would be very happy if someone helped me.
thanks
first image
second image
Your ISP might have put you under a NAT, in that case port forwarding might still not work.
Your best bet is to use some sort of SSH Tunnels.
You can try with ngrok.
This will give you a URL to access your application from public internet.
Only caveat here is that ngrok is not free. They have a subscription based model. In the free tier, you can use ngrok but the link url changes after few hours.
If you want to, you can also implement something like ngrok for yourself. Read about ssh tunneling more. This will help you.

port number in URL

we currently have a web service hosted on our server and the link to the service is something like this: www.something.com:8041/MyService.asmx
our client cant open that link in their browser or connect to the service through the app. They found out that port 8041 is blocked.... this doesnt make sense to me, that port number is in the URL why would blocking ports have anything to do with that? its not looking the request is going out through port 8041?
We are going to unblock port 8041 at the client but that doesnt make sense, the port 8041 is for our servers benefit and has been unblocked...
No, actually going to http://www.something.com:8041/MyService does in fact go through port 8041, and if you have a group of clients sitting behind one firewall (e.g. business 1) trying to access a server behind a second firewall (e.g. business 2), you need to make sure both firewalls are setup to allow this.
If you don't want to have to go around opening ports, a common solution is to configure a webserver (nginx, varnish, etc.) that is listening on port 80 (or 443) that reverse proxies to whatever service is listening on the non-standard port.

Access virtual machine from remote server

In my work we use VirtualBox for development so sometimes it gets a little bit tricky when it comes to testing.
Actually I'm working on a payment platform and I have to integrate with PayPal Instant Payment Notifications.
The idea is that when a Paypal transaction is approved, PayPal sends an IPN message to my server and that is the problem.
Is there a way I can make my local development server available so PayPal can access it?
Thanks in advance.
I assume your server is running inside the VirtualBox, right?
So you will have to give the VirtualBox machine an IP that your company router can relay the PayPal IPN message to. That IP should also be a static IP (not by DHCP) so the routing on the router could be set accordingly.
(The following works well, I have done it successfully numerous times)
To do that:
Setup the VirtualBox to have the IP from the company router: In VirtualBox adapter go to the 'settings' of that said VirtualBox, click on 'Network' and change 'Attached to' to 'Bridge Adapter'.
Launch the VirtualBox and change the IP of the machine to a static IP allowed by the company router.
Create on the company's router a routing ('Virtual Server') from a specific socket to this static IP. For example, for socket 1234: http://YourDomain.com:1234
Then you give the PayPal server this domain with socket. any communication on this socket would be routed directly to your server inside the VirtualBox.
Hope that helps!

publish jax-ws service on public ip

I've a simple jax-ws web service that on localhost works fine with the clients, but now I want to publish the web service on a public ip, so the clients can interact with it through wan network instead lan network.
I signed to no-ip dns service provider and defined my host like "myname.no-ip.info".
In my code i start the service in this way:
Endpoint.publish("http://localhost:8080/baseStationProvider", new BaseStationProvider());
and the browser at http://myname.no-ip.info:8080/baseStationProvider#wsdl doesn't show the wsdl.
If i start the service in this way:
Endpoint.publish("http://myname.no-ip.info/baseStationProvider", new BaseStationProvider());
compiling the code, it raise this exception:
Server Runtime Error: java.net.SocketException: Unresolved address
Any idea to problem and/or how to do what i need?
thanks in advance
This seems likely to do with routing and firewalls as opposed to web service publication etc. Ignoring the web-service aspect, can you even reach your server when you use this in your browser:
http://myname.no-ip.info:8080/
?
Which should look the same as
http://localhost:8080/
If not, then it is probably DNS/Routing/Firewalls that you need to check. Diagnostics that will help there are:
1) can the machine you are testing on resolve the DNS name mynam.no-ip.info? nslookup, ping, traceroute/tracert
2) is there a firewall blocking port 8080 from reaching local host? If the route from the internet to your host hits a firewall (which it will) that firewall will have to forward the request.
Good luck.

Testing a remote web service with soapUI

I have a Javax web service deployed in a remote Linux machine within a JBoss ESB container. I am able to test the web service using soapUI on the same machine as where the service is deployed. The WDSL URI I used was something like http://127.0.0.1:8080/abcd/abcd?wsdl.
What I would like to do is to be able to test the same service from another machine using soapUI. I tried replacing 127.0.0.1 with the IP address of the machine where the service is deployed. This does not seem to work. Can someone tell me what I am missing here?
Thanks.
a sum of things could go wrong there - as already mentioned by the others the firewall is blocking access for the given (address, port) pair. Another thing that happened to me was that the WSDL was generated using the name of the machine it was deployed on and whenever I was trying to call the service from a different machine it was complaining that I cannot find the given machine.
You need to test network connectively. One tool you can use is plain old telnet. If you telnet to the ip/port combo of the web server, you will get a response (an HTTP error). For example:
$ telnet 192.168.0.10 8080
If you get nothing then there is almost certainly a firewall blocking access.
If you are convinced that no firewall is blocking you, the other possibility is that the web server is only bound to the local network adapter (127.0.0.1) and not the other network adapters (ethernet/wifi). This is very unlikely however.