Can I still do port forwarding in order to make my local website public if I have two routers between me and the internet? - web-services

I am trying to host a website from my house. (It does not have to be very reliable and consistent, hence I'm hosting from my house from a Raspberry Pi).
My website is obviously working fine locally. I tried to configure port forwarding on my router. It did not work. I then realized that my IP address on https://www.whatismyip.com/ and my router IP address is not the same. After reading up I am suspecting that I am behind another router. That would make sense since I'm living in an estate/housing complex and one ISP provides internet to all units. I can't access the next router (probably due to security reasons from my ISP).
My question is, is there any way around this? Would an ISP in general perhaps grant me a port if I ask them?
P.s. I am using phpmyadmin with my website and I am using Java on a cron-job to execute a program every 2 minutes which changes the DB. So I am not sure website hosting on a third party site would be trivial in my case.

it works now. I emailed my ISP to ask about the situation. Without further questions they assigned me a public IP address. I configured port forwarding and it works. Seems like you only get a public IP if you ask for one.

Related

How to find IP address of application (for instance Drive)?

I am using an app called SelfControl. It blocks all Internet traffic as not to distract me, but the app allows you to make a whitelist of sites or services that can be accessed. However, although sometimes the IP range is mentioned on an app's website, this is not always correct, and the app is still blocked.
So, using Terminal or any other default program, how do I find the exact stream URL or IP address a particular app is using (for instance Drive or Spotify)?
PS. I considered SuperUser, but as the solution may involve a few lines of code I thought SO was more appropriate.

How do I access my Django server from outside?

My computer is connected to our college's local network. I am able to access my django server in the same network from another computer. When I try to do the same from an outside internet connection, I get an " Webpage not found error" . I used the ip given by Whatsmyip.com to access it from outside. Also, I started the server using the command : python manage.py runserver 0:8000
Use something like:
LocalTunnel http://localtunnel.me/
Ngrok https://ngrok.com/
These create a tunnel to your localhost. You cannot host from a common IP shared by an internal network. Read more about localhost here: http://en.wikipedia.org/wiki/Localhost
Please note that the tools above allow you to share a link to your site and is mostly meant for development and testing. If you really want to host a Django server, either do it on an external server or contact your infrastructure team in college to see if they even allow such a thing.
For external hosting, Heroku (https://www.heroku.com) can be a good option with a reasonable free plan.
This depends on your college network. Often, computers in local networkds are behind a NAT (one single external ip for several clients). At this point, the request cannot be routed from out- to inside. Maybe a college technician can help you to route your page.
I think it's first important to note that manage.py runserver is for local development. It is not meant to be used for deployment.
If you want to access your website from "outside", you should consider deploying it. You can then read more about this here : https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
Also, like stated in other answers, depending on how is configured your college network, it may not be possible to access your development server from outside, because :
It probably has NAT rules for local networks
There are probably port restrictions and a firewall for outside access (usually college networks are very restrictive from inside AND from outside)

Acting as a server outside LAN

I'm currently writing a peer-to-peer chat application to chat around the world, but my problem is that I can't connect() to another computer outside my LAN because although I have the public IP address of my friends and if necessary I could get their private IP address, how can I connect to their PC since the public IP address is the router's address, not the computer's one and I can only specify one address (either the public or the private). So how can I send the message to the computer in specific and not to the router without having to setup it?. I know it's possible because otherwise if you requested a web page all the computers in your lan can get your private information (in a wired scheme, since in wi-fi it's clearly possible).
Any help would be appreciated, sorry for my poor English :D.
There are two possibilities:
1 Read around here: http://en.wikipedia.org/wiki/STUN
2 Go for IPv6! ;-)
Actually the private IP address of computers on the other side of the router will not help you. In these situations, if they initiate the connection to you, then you are fine as you can respond on that connection.
If you want to initiate the connection to them, you must to it to their public IP address and they must have their router configured to map the inbound request (on whatever port) to the correct IP address in their network.
First, you need to be sure that the computer you are trying to connect is listening to a specific port (the same one that you are trying to connect to).
You will also need to configure your friends routers so that they forward all the request on that port to your friends' computers. If you don't have access to the routers, it is probably best to use a computer that is not behind any router as the chat server.
The ideal solution is to use uPNP. This allows your application to talk to the router(s) on the current network and ask them to forward the appropriate messages to you. This then makes a hole in the firewall which allows your app (on another PC) to connect.
Assuming both apps do this, either end can initiate the connection. If only one end has the app, then the OTHER end must initiate connection.
Imagine what would happen if everyone on the internet could just send messages to anyone - with no software pre-installed...

How to get IP address of your application server

I need to be able to find the IP address of the server the page is currently executing on. I have some code that calls a third party site and has to pass a specific key that changes depending on which server it is on. Is there a CGI variable or some way in ColdFusion to determine what the IP address is of the host server?
Like the other commenters have outlined if you need the external IP as the third party site sees it then you probably should use the external approaches they recommend.
However if the third party is giving you access in some form that is based on an actual IP as the Server sees itself and not the IP as they see it you can use
<cfset cName = CreateObject("java", "java.net.InetAddress").getLocalHost().getHostAddress()>
<cfdump var="#cName#">
There are two reasons why a program can't query the host it's running on and see what its IP is:
It might have multiple ips, and short of looking through all sorts of kernel data structures you're unlikely to know which one is going to be used for a given outgoing connection.
It might connect to the outside world though a NAT firewall or some sort of proxy so that the outside world will see a different IP than any of the ones configured on your box.
Actually, there might be more than those two, but those are ones that have occurred to me.
Because of that, the simplest way is to connect to another box somewhere outside of your corporate network and see what IP it thinks you have. I use a two line CGI script running on my colo box to detect what IP my home server currently has (so I can detect when the cable company changes it).
You can use CGI.LOCAL_ADDR to determine the IP-address of your server (CFML equivalent to PHP's $_SERVER["SERVER_ADDR"]). It works on IIS and Apache using ColdFusion or Railo, given you are not behind a Proxy, not natting your server IP and having only one IP assigned to your server (not sure which IP would be shown, if there are more than one).
I would use hostip.info API
Your IP in XML: http://api.hostip.info/get_xml.php
Your IP in HTML: http://api.hostip.info/get_html.php
The safest way will be to use a service like WhatIsMyIP. If the server is behind a NAT, then the OS has no knowledge of the external IP address.
There are many questions in SO regarding this, see here for example.
<cfhttp url="http://www.whatismyip.com/" result="myresult" resolveurl="yes">
<cfoutput>#myresult.filecontent#</cfoutput>

Mac OS X web sharing and Django

I created a web app with Django and I have it running on localhost (http://127.0.0.1:8000/), my question is, how can I make it available to the world, using Mac OS X's web sharing or something?
Thanks!
While you start the server specify the public ip or for any ip use 0.0.0.0
Example:
sudo python manage.py runserver 0.0.0.0:80
If you start your application without ip and port its bind only for loopback which is 127.0.0.1 and will not accessible in your network.
First off, I would strongly suggest you not to serve a website from your Mac. It's a really bad idea™. Both Mac OS X web sharing and Django's included http server (which I assume you're using) are intended for testing purposes only, for a number of reasons concerning speed, security et al. which is frankly too long to post here (but I hope that someone will :)
Second, it's already open to the world: anyone can connect to your computer using your IP address instead of the loopback 127.0.0.1 (unless you're NATted). This, again, is quite useful to test it (and have your friends/colleagues/boss) test it temporarily, but again is not fit for production use. Really.
It depends what your real purpose is, what you mean by "available to the world...or something". If you do want it to be permanently accessible from the web, you need to host it on a server (be it shared or dedicated), you won't keep your Mac turned on forever, will you? :)
For hosting Django on shared hosting - I'd recommend webfaction, step-by-step tutorials on setting up Django project can be found in their screencasts and forums (9.50$ per month for basic plan, with two months money-back guarantee, which actually works, tried myself:). More options in Djangofriendly.com
For dedicated server, ask yourself if you favor managing whole server(OS, web server, database server, memcache, firewall, backups...)yourself. If the answer is "yes", check out Linode, Rackspace, or Slicehost or even amazon web services, but bear in mind it's more expensive, it's way more complicated, but that's what gives you the ultimated flexibility. Once you are ready to try - this is one of the best tutorials i've found in net for a given subject.
If all you need is a proof of concept, that "whatever i can access from my web browser, should be accessible from anywhere in the world", ask your ISP if you are given the private IPaddress. If not, hm, better go for options mentioned above :) If you do, then find out what IP it is by visiting whatismyipaddress.com. Then start the web server as Prashanth suggested, and enter the IP address from whatismyip.org in your browser. Get nothing? a)turn off firewall of MacOSx. still nothing? b)connect your Mac directly to ethernet cable your ISP provides, without router in between. Retry entering your ouside IP in the browser. Works? great, go google "Port forwarding ", this will tell you have to configure your router to have the same effect when router is being used. Doesn't? Ask separate question in stackoverflow and provide as much details about what you are doing as you can.
Mac os Web sharing is uselless if the packets aren't routed correctly to reach your computer on a network. I guess all it can do is start apache, and open some ports in a firewall. But if your personal router or ISP wont forward external packets to your computer - you won't get what you want.
Good luck!