I have a DSL modem with a public IP address (201.206.x.x), and I have a web server in my internal network (192.168.0.50).

I set up the modem to forward requests to port 80 to my web server, so, if I access 201.206.x.x from outside my network, it shows my web page, the same happens if I access 192.168.0.50 from a computer inside my network.

Now, the problem is when I try to access 201.206.x.x from my internal network, the browser tries to connect to the DSL modem configuration, instead of redirecting my request to my Web server.

Which settings do I have to change in the modem to set up this redirection?

link|improve this question
feedback

migrated from serverfault.com Mar 20 '11 at 17:36

This question came from our site for system administrators and desktop support professionals.

5 Answers

The problem is that the packet rewriting can generally only take place when traversing the firewall. Generally speaking routers cannot perform the necessary re-writing when the request is arriving from the same network the request would be re-written to. The common solution to this problem is to place a web proxy outside the network that loops the request back through your firewall.

I suspect your specific problem is that you would like to access the web site via its DNS host name. You can handle that by using "split-horizon" DNS, so it pays attention to where the request is coming from and answers appropriately: If the request is coming from inside your network, it hands out the 192.168.0.50 to requests coming from your network and the public IP to everyone else.

Either of these suggestions could be implemented on any host outside of your network, like a (free) Amazon EC2 micro instance.

link|improve this answer
Thanks, although I think I will stick with the HOSTS file editing since it's basically a personal site that I use for tests of sites I'm working on. The PC isn't even up 24/7. – willvv Mar 20 '11 at 5:13
1  
I solved this problem on my own home network by adding an A record with the same name as my external dyndns name on my own DNS server (also running on my home network). The A record points to the proper location in my home network, as does the reverse PTR record. But of course, not everyone is running their own home DNS... – ultrasawblade Mar 21 '11 at 0:25
feedback

I would say @Insyte is onto something when he/she talks about the issue being a DNS resolution issue .. which then means the problem is packet rewriting (read @Insyte post again for that explanation).

But what @Insyte didn't suggest was an easy solution :)

So, assuming you have the following things setup (which u did say is setup .. so i'm just confirming / clarifying )

  1. Public Ip: 201.206.x.y
  2. Private IP; 192.168.0.50
  3. Port forwarding for all 80 (and 443 if u're doing SSL) on ip 201.206.x.y -> 192.168.0.50

you then type the following, in your browser ... while you're in your internal network

http://www.yourwebsite.com

and the error occurs.

So, solution: hack your hosts file :) Add this to your hosts file.

192.168.0.50 www.yourwebsite.com

and then restart your browser, enter the url and viola! it's working. So this means, your browser doesn't rely on your DNS to resolve your domain to the ip. Instead, we're overriding this and saying 'please browser, just goto my internal iP for that domain name, instead of asking DNS for the IP addy'.

If you're in an office, then u can get all the people who need to access this internal website, to hack their hosts file OR if u have an internal DNS, then u can add an entry into that. Another idea is to have an internal proxy server (for all web surfing, etc) and then hack the hosts file on the PROXY SERVER :P This means your browser will say 'Proxy, can u please get me the resource http://www.mywebsite.com' and the proxy the says 'sure .. and because i've been told to ignore dns for that domain, i'll just give the ip which has been hardcoded in my hosts file'.

Viola!

UPDATE: what's hacking the hosts file? on windows, goto C:\windows\system32\drivers\etc\hosts (notice, there's no extension on that file).

if you open that file up in notepad, u can then see any entries that are used to override DNS. If u wish to update that file, you will need to open Notepad (or whatever program you're using to edit the file) with Administrator rights - otherwise u can't save the file (and u get an error message).

link|improve this answer
Yep, I actually had this before I posted, I just wanted to be able to access it throught the actual IP, but I think I can live with that since my modem doesn't have NAT reflection (as suggested by @MaQleod). – willvv Mar 20 '11 at 5:12
What about a laptop or smartphone that is frequently accessing the same site via internal or external network? – TREE Mar 20 '11 at 13:23
@TREE can u please elabourate. I didn't quite understand your question. – Pure.Krome May 20 '11 at 11:43
I have a very similar setup, except I'm using domain names. So from outside the network my domain resolves to my external IP, and from inside, it resolves to the internal IP. I have laptops and smartphones that frequently access from inside and outside, so hacking the hosts file wouldn't work. What I have done is basically what your (Pure.Krome) other answer suggests, only instead of using an external server I'm just telling the DHCP server on the router to prepend an internal DNS server. It mostly works, but there are annoying lags when switching networks before things start resolving. – TREE May 22 '11 at 14:41
feedback

This is a common problem with the way some routers handle traffic meant for their public address from an internal address - they don't follow the same port forwarding rules as requests from outside the network. What you need to look for in your routers is NAT reflection. This will allow the router to handle internal requests for the public IP to use the same port forwarding rules as if the request came from outside the network.

link|improve this answer
NAT reflection. I think that's what I was looking for. Unfortunately my modem doesn't have that. Thanks! – willvv Mar 20 '11 at 5:10
feedback

I could help you better if you could give me your modem make and model...

But what happens here is that normally a router or modem config page should only appear when visiting their internal IP (192.168.0.1)

But what seems to be happening here is that it Identifies the incoming request (201.206.x.x) As coming from the inside so decides to give you the config page instead of the normal route to your web server...

Now if you're using a Consumer level modem, you probably aren't able to change this (sorry)

But maybe you can: Try and see if there is 'listen' settings in your admin config page

There you can try to either change your administration page to another port Or limit the adresses its listening for

link|improve this answer
feedback

Maybe the problem is that remote administration is allowed.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.