With multi-router set up, upnpc maps to secondary router ip instead of external ip - port

I'm trying to use UPnP to open a port, so I'm experimenting with miniupnpc. I've observed a handful of people use and suggest upnpc -a <internal ip> <internal port> <external port> <protocol> to open the specified external port and point it to the application running on the specified internal port.
Before I continue, I will note that UPnP is on in my router's settings, and that it lists a few connections, though when I check them with a port checker I find that none of them are actually working? Or at least none of them seem to be open.
When I try to map the internal port 5000 to the external port 7777 with the following command:
upnpc -a 192.168.1.10 5000 7777 tcp
What I find is that it "works" without any explicit errors, but
the external ip it maps to isn't really an external ip at all. Here's the output following the command given above:
upnpc : miniupnpc library test client, version 2.1.
(c) 2005-2019 Thomas Bernard.
Go to http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
for more information.
List of UPNP devices found on the network :
desc: http://192.168.1.1:5000/Public_UPNP_gatedesc.xml
st: urn:schemas-upnp-org:device:InternetGatewayDevice:1
Found a (not connected?) IGD : http://192.168.1.1:5000/Public_UPNP_C3
Trying to continue anyway
Local LAN ip address : 192.168.1.10
ExternalIPAddress = 192.168.0.153
InternalIP:Port = 192.168.1.10:5000
external 192.168.0.153:7777 TCP is redirected to internal 192.168.1.10:5000 (duration=0)
Obviously, 192.168.0.153 is not an external IP Address, and yet it seems to be treating it as though it is. Why might this be?
EDIT: Upon further inspection, it seems like since I have a multi-router set up, the "external ip" here is actually the internal ip of the secondary router. I wonder why this is, though, and whether it can be circumvented.

Related

Cant connect to External IP

I'm trying to connect to my public IP http://34.125.119.106:8080/, where I have a Jenkins service running but I can't and don't know why.
I've create firewall rule to allow tcp traffic on port 8080, which is the port exposed to Jenkins, but I still cannot connect. I looked into the /etc/default/jenkins file, to see if everything inside was configured correctly. I tried to line in this file like 'HTTP_HOST=127.0.0.1', like some people advise to do ,but it doesn't work for my case. Does anyone know how to solve this?
Sorry for my bad English.
enter image description here
i made a test and it successfully connected,but i still cant connect to my external Ip
Use the default settings, because HTTP_HOST=127.0.0.1 locks you out:
HTTP_HOST=0.0.0.0
HTTP_PORT=8080
HTTPS_HOST=0.0.0.0
HTTPS_PORT=443
Listing to all interfaces with 0.0.0.0 is fine, but HTTP_PORT should be -1.
As a first step my recommendation is to check if your service is exposed and through what port number. For this you can use command sudo netstat -plntu. You should be looking for an output similar to:
tcp6 0 0 :::8080 :::* LISTEN 17917/java
If its not, change your /etc/default/jenkins file to port 8080
After that from inside your GCP project, you can run a connectivity test having as source one of the IP addresses you are using to reach your Server and as destination your Servers VM instance IP address. This test will simulate traffic and tell you where it's getting stuck whether if it's stuck on the way to your Server or if your server is not correctly configured. You can get a good reference in this document.
If you have already configured your ingress firewall rule, just make sure its applied to your VM, it sometimes happens that you have a network tag on your VM instance and another tag on your firewall rule.

Sonoff RF Bridge to Mosquitto (on Windows) Configuration

I've been searching high and low for a simple explanation for this. What configuration settings do I use to connect my Sonoff RF bridge to the Mosquitto server on my computer? I'm sure it's a configuration issue but most of the tutorials out there are for rPi. My skill level in this is basic and I'm sure it may be obvious to someone what's wrong.
I'm running Mosquitto on Windows 10 and have verified that the Mosquitto server is running using netstat -a (I can see the broker is listening at 0.0.0.0:1883.
I've installed Tasmota Eclipse on my Sonoff RF Bridge and have verified it is receiving signal from my door sensor by opening the UI in my browser and viewing the console. I've tried multiple host addresses in the configuration menu; localhost, 0.0.0.0, 10.0.0.1, however Tasmota only seems to connect when I leave the host field blank.
I've tried to use MQTTlens to verify that the broker is receiving messages on port 1883 and nothing seems to be coming through.
0.0.0.0 is a short hand to tell mosquitto to listen on all the available interfaces on the machine it is running on. It is meaningless to use it in the client configuration.
Likewise, localhost always means the same machine that the code making the request is running on, so in this case it would be the Sonoff device it's self.
It looks like 10.0.0.1 is the address of your local router, unless mosquitto is actually running on the router (it is very unlikely your windows machine is your router) this again is not going to be useful.
You need to use the IP address of the Windows machine that mosquitto is running on, this is going to start with 10.0.0. running ipconfig on the command line in windows is probably the quickest/simplest way to find that address.

Port Forwarded; Port Check says port is open but unable to connect

I have setup the Swann DVR Surveillance System. I am able to access the web client at 192.168.1.99:85 (static ip in internal LAN). I have port forwarded 85 packets to 192.168.1.99. But when I access my external ip eg xxx.xxx.xxx.xxx:85 I get unable to connect error.
I checked if the port is open in an online tool and it says port 85 is open. HEre is my port forwarding page:
Please Help me. Thanks in advance
EDIT: I have tried changing ports to 89, 9001, 8080 and no luck..
Ive finally figured out what I was doing wrong from a friend. It seems there is something called NAT Loopback (https://en.wikipedia.org/wiki/Network_address_translation#NAT_loopback) that allows you to access your public IP address from within your own network. Most routers have this feature disabled by default. And hence whenever you try to access your IP address the packets are dropped and you get the Host Unreachable ICMP packet.
Anyway to use this try to enable NAT Reflection or NAT Loopback on your router.
If you dont have that feature, you can test your system from outside the network and itll work just fine. Sorry for not reporting the answer sooner.
Yeah, same problem. As Steve Robinson said, you cannot always access your public IP from your NAT. Try running Apache and use your phone (turn off WiFi and turn on mobile data) to test if this is the case.

How do you host a Ruby on Rails application on a local network, so multiple people can access it?

I'm brand new to RoR and have pretty much 0 experience with it. I have been handed down somebody else's project and I need to find a way to host the application, so people can just access it locally. The application is a spider script/walker script/web scraper whatever you call it. Basically it connects to a website, logs in, retrieves certain data each day and maps it with the previous data. While on the local machine, you use it, go to localhost:3000, and you get the webpage the previous person designed. I was just wondering how I could get that page to be public for the people on our local network, so they could connect to some arbitrary IP and see the same page (it updates daily)?
What I tried doing is making the folder containing the application public to the network, but in order to use it, I would have to make everybody on the network allowed to write to it and each person would have to install RoR to use it. I want to avoid that since it doesn't seem logical, nor is it what I'm trying to do.
Looking at the code, I can reverse engineer and understand what it does, but when it comes to hosting web apps locally or something of that sort, I have never done this before. Please help!
Thanks in advance!
**EDIT
-This is all being done on a Windows 7 machine.
Since you're on Windows, open up a command line and run ipconfig to find out your local IP. It will be listed under 'IP Address'.
Tell people in your LAN to access http://192.168.x.x:3000 replacing 192.168.x.x by your IP address from step 1.
EDIT: One major thing that I missed, you are windows. On windows u could use thin and put it behind a load balancer. Although i would suggest hosting it on a UNIX machine :)
Although Running it in webrick(webrick is the application server for development i.e when u run rails s) will let other users access the website NEVER do the same for a production application. If you want to run this application in production, u need more powerful application servers like passenger. I would suggest you use it with Apache or Nginx instead of stand alone passenger. Once all this is setup others can use your application by entering the IP(xx.xx.xx.xx) also u can ask your system admin to setup a local DNS so your users need not remember the IP address always.
Description:
While starting Rails Server, we can also setup some options to configure the IP address and also the port number of the site under development environment to host the website in local network. So if we want to change the IP from http://127.0.0.1:3000 to http://192.168.x.x:port (x= 0 to 255 any one number), we can set that in Rails server command! But for this, we will need to find out our current IP address at our current network which will help us to serve the website in local network.
So at first step:
We will open our terminal on our PC. For Android user, we need to open Termux app. Then simply type ifconfig to get the IP address of our device in the current network. We will get an output like this one (Here I'm using Android device for development. So output might be something different than this one on your PC terminal but the process is same):
$ ifconfig
Warning: cannot open /proc/net/dev (Permission denied). Limited output.
lo: flags=XX<UP,LOOPBACK,RUNNING> mtu XXXXX
inet 127.0.0.1 netmask 255.XXX.XXX.XXX
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen XXXX (UNSPEC)
wlan0: flags=XXXX<UP,BROADCAST,RUNNING,MULTICAST> mtu XXXX
inet 192.168.1.103 netmask 255.XXX.XXX.XXX broadcast 192.168.1.255
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen XXXX (UNSPEC)
X= some numbers with our device credentials which is dummied with this variable
If you are using a WiFi router then we will need the wlan0 part to get our device IP. Under wlan0 section there is a subsection of inet showing our current IP! YUP, we need that IP address 192.168.1.103! This might be different for your device and network. This is the key of this mission! Now we're going to the second important step.
So the Second Step is:
That required input command to configure the IP address.
rails s -b 192.168.1.103 -p 8080
Here:
rails s for rails server
-b 192.168.1.103 for bidding the IP address for customisation from the default IP http://127.0.0.1 which is our localhost address.
-p 8080 for port setup. This part is optional. Default port is 3000.
This is the process of changing the localhost IP (http://127.0.0.1) to local network IP which will be available for other device of the same network user.
Now our rails app is available in our local network! Other users in the same network will also be able to visit the website while the server command is running. And the link will be http://192.168.1.103:8080 if you also configure the port number. Otherwise if you have used the command rails s -b 192.168.1.103 without port configuration the link will be: http://192.168.1.103:3000
Again: 192.168.1.103 was for my case, your IP address will be different for your device. That will be needed to use for your server and link address.

How to find Port number of IP address?

We can find out IP address of a domain name or URL. But how to find out Port number on which a domain name is hosted?
Unfortunately the standard DNS A-record (domain name to IP address)
used by web-browsers to locate web-servers does not include a port
number. Web-browsers use the URL protocol prefix (http://) to
determine the port number (http = 80, https = 443, ftp = 21, etc.)
unless the port number is specifically typed in the URL (for example
"http://www.simpledns.com:5000" = port 5000).
Can I specify a TCP/IP port number for my web-server in DNS? (Other than the standard port 80)
Quite an old question, but might be helpful to somebody in need.
If you know the url,
open the chrome browser,
open developer tools in chrome ,
Put the url in search bar and hit enter
look in network tab, you will see the ip and port both
DNS server usually have a standard of ports used. But if it's different, you could try nmap and do a port scan like so:
> nmap 127.0.0.1
The port is usually fixed, for DNS it's 53.
If it is a normal
then the port number is always 80
and may be written as http://www.somewhere.com:80
Though you don't need to specify it as :80 is the default of every web browser.
If the site chose to use something else then they are intending to hide from anything not sent by a "friendly" or linked to.
Those ones usually show with https
and their port number is unknown and decided by their admin.
If you choose to runn a port scanner trying every number nn from say 10000 to 30000 in https://something.somewhere.com:nn
Then your isp or their antivirus will probably notice and disconnect you.
Use of the netstat -a command will give you a list of connections to your system/server where you are executing the command.
For example it will display as below, where 35070 is the port number
TCP 10.144.0.159:**52121** sd-s-fgh:35070 ESTABLISHED
Port numbers are defined by convention. HTTP servers generally listen on port 80, ssh servers listen on 22. But there are no requirements that they do.
domain = self.env['ir.config_parameter'].get_param('web.base.url')
I got the hostname and port number using this.

Resources