Two local IP addresses, cannot see my own webserver!

P

Peter Hucker

The setup is as follows:

PC 2 has a USB broadband modem and is permanently connected to the internet with a fixed IP of 80.229.155.158.
PC 1 (the one I'm typing this on and what I use most of the time) is connected to PC 2 through a crossover ethernet cable, and has address 192.168.0.2 (PC 1 is 192.186.0.1 and is running Internet Connection Sharing).
Both PCs are running Windows XP Professional Service Pack 2.
PC 1 has apache webserver running serving the pages below.
The main html of each page is on plusnet's servers, but all the sub-parts are on my own server (on PC 1) as plusnet doesn't have enough space.
Pages work fine for everyone except me (using PC 1).
Parts of the page refer to 80.229.155.158, which I should surely be able to map to 127.0.0.1 or 192.168.0.2?!?
I've tried editing the hosts file, but it seems to ignore IPs and only allows mapping of text addresses such as www.microsoft.com?

--
*****TWO BABY CONURES***** 16 parrots and increasing http://www.petersparrots.com
93 silly video clips http://www.insanevideoclips.com
1259 digital photos http://www.petersphotos.com
Served from a pentawatercooled dual silent Athlon 2.8 with terabyte raid

_..._
\_.._ `'-.,--,
'-._'-. `\a\\
'. `_.' (|
`7 ||
/ .' |
/_.-' ,J
/ \
|| / ;
_.. || | | /`\.-.
.' _ `\ `\ \ | \_/__/
/ /e)-,\ '. \ /.-` .'\
/ | ,_ | /\ `;_.-'_.-'`\_/
/ '-(-.)/ \_;(((_.-;
.'--. \ ` .(((_,;`'. \
/ `\ | _.--'`__.' `\ '-;\
/` | /.-' .--' '._.'\\
.' ; /__.-'` | \ |
.'`-'_ /_.'))) \_\,_/
/ -'_.'---;`'-)))
(__.'/ /` .'`
(_.'/ /` /`
_|.' /`
.-` __.'|
.-'|| |
\_`/
`
 
R

Ron Lowe

Peter Hucker said:
The setup is as follows:

PC 2 has a USB broadband modem and is permanently connected to the
internet with a fixed IP of 80.229.155.158.
PC 1 (the one I'm typing this on and what I use most of the time) is
connected to PC 2 through a crossover ethernet cable, and has address
192.168.0.2 (PC 1 is 192.186.0.1 and is running Internet Connection
Sharing).
Both PCs are running Windows XP Professional Service Pack 2.
PC 1 has apache webserver running serving the pages below.
The main html of each page is on plusnet's servers, but all the sub-parts
are on my own server (on PC 1) as plusnet doesn't have enough space.
Pages work fine for everyone except me (using PC 1).
Parts of the page refer to 80.229.155.158, which I should surely be able
to map to 127.0.0.1 or 192.168.0.2?!?
I've tried editing the hosts file, but it seems to ignore IPs and only
allows mapping of text addresses such as www.microsoft.com?



I think this may ba a manifestation of a common issue.

You may not be able to refer to another machine on your LAN using it's
public IP address because the NAT doesn't do loopback.

IOW, from within your LAN, the NAT ( sharing ) machine will only be
contactable on the Internal IP ( 192.168.0.2 ) but not on it's external IP
address.

Normally, you need to use the hosts file internally to point to your
external domain name to the internal IP address.
Leave external DNS for your domain pointing at the external address.

But then you won't be able to hit the home page at your ISP.

How would I do it?
Something like this:

External DNS:
www.yourdomain.com -> IP address of ISP's hosted page.
www1.yourdomain.com -> External IP address of your server.

In the home page, don't refer to the IP address of the home-hosted page,
but refer to www1.yourdomain.com.

Internally:
Add this to your hosts file:

192.168.0.2 www1.yourdomain.com

Now, name resolution for the www1 machine should resolve to the external IP
address for everyone on the outside, but to 192.168.0.2 for you on the
inside.

You still get the external IP address for the ISP-hosted page, becuase we
didn't over-ride DNS with hosts for the www. homepage.
 
P

Peter Hucker

I think this may ba a manifestation of a common issue.

You may not be able to refer to another machine on your LAN using it's
public IP address because the NAT doesn't do loopback.

IOW, from within your LAN, the NAT ( sharing ) machine will only be
contactable on the Internal IP ( 192.168.0.2 ) but not on it's external IP
address.

Normally, you need to use the hosts file internally to point to your
external domain name to the internal IP address.
Leave external DNS for your domain pointing at the external address.

But then you won't be able to hit the home page at your ISP.

How would I do it?
Something like this:

External DNS:
www.yourdomain.com -> IP address of ISP's hosted page.
www1.yourdomain.com -> External IP address of your server.

In the home page, don't refer to the IP address of the home-hosted page,
but refer to www1.yourdomain.com.

Internally:
Add this to your hosts file:

192.168.0.2 www1.yourdomain.com

Now, name resolution for the www1 machine should resolve to the external IP
address for everyone on the outside, but to 192.168.0.2 for you on the
inside.

You still get the external IP address for the ISP-hosted page, becuase we
didn't over-ride DNS with hosts for the www. homepage.

But there is no domain for my external IP. Why can't I put:

127.0.0.1 80.229.155.158

in the hosts file?



--
*****TWO BABY CONURES***** 16 parrots and increasing http://www.petersparrots.com
93 silly video clips http://www.insanevideoclips.com
1259 digital photos http://www.petersphotos.com
Served from a pentawatercooled dual silent Athlon 2.8 with terabyte raid

.--.
|/`-\
__ _( '\'
_.-' | __(,
.' _.-' \/ %;
/\.' / ;%,
\/ '.__.-' '#;
| / ;%,
\ || '`
\ ||
| ))
| ||
|__||_
| '.__)
'._)
 
L

Lanwench [MVP - Exchange]

Peter said:
But there is no domain for my external IP. Why can't I put:

127.0.0.1 80.229.155.158

in the hosts file?

Because that isn't what hosts does. It maps hostnames to IPs, doesn't
redirect one IP address to another.

I strongly suggest you buy a little gateway/router/firewall appliance, put
it between your DSL modem and your network, and disable ICS. It works a lot
better in general. Keep everyone on the same local (private) IP subnet. Use
a static IP for your server, and DHCP if you like for your workstations.

Windows makes a lousy router, if you ask me -and ICS is dreadful stuff.
 
R

Ron Lowe

But there is no domain for my external IP.

Then I think you need to create a host entry for it.
It's simply a matter of adding an extra A- record in the DNS provider that's
hosting your first domain.
Or if that's not possible, use a 3-rd party DNS provider and give the
home-hosted pages a completely different name.

The end result is that both need to be accessible by name.
( By different names. )

Then can you have external hosts resolve one IP address, and internal hosts
resolve another.
Why can't I put:

127.0.0.1 80.229.155.158

in the hosts file?


Because that's not how the hosts file works.
The hosts file is a static Name Resolution database, not an IP redirector.
 
R

Ron Lowe

Because that isn't what hosts does. It maps hostnames to IPs, doesn't
redirect one IP address to another.
Right.


I strongly suggest you buy a little gateway/router/firewall appliance, put
it between your DSL modem and your network, and disable ICS. It works a
lot
better in general. Keep everyone on the same local (private) IP subnet.
Use
a static IP for your server, and DHCP if you like for your workstations.

Windows makes a lousy router, if you ask me -and ICS is dreadful stuff.


But that won't help with his original problem.

His server will now be on a NATted address, say 192.168.0.2.
He will need to forward port 80 from his public IP to the server.

And once again, external hosts can connect using the External IP,
Internal hosts can connect using the Internal IP.
BUT:
Internal hosts will usually not be able to connect using the External IP.
Because most NAT routers won't loop-back like this.

So you've got to over-ride DNS using the hosts file for internal clients:

hosts:
192.168.0.2 www.mydomain.com

Now, external clients get the DNS entry, and connect to the router's
external IP,
but internal clients get the hosts over-ride and connect to the internal
192.168.0.2 IP.

However, this is more complex because the site is split.
Some pages are hosted externally, and some are hosted internally.
So we need 2 seperate DNS records:

One for the external main homepage, which both Internal and External clients
will use,
and one for the home-hosted pages which can be over-ridden for internal
clients.
 
L

Lanwench [MVP - Exchange]

Ron said:
But that won't help with his original problem.

His server will now be on a NATted address, say 192.168.0.2.
He will need to forward port 80 from his public IP to the server.
Yep.

And once again, external hosts can connect using the External IP,
Internal hosts can connect using the Internal IP.
BUT:
Internal hosts will usually not be able to connect using the External
IP. Because most NAT routers won't loop-back like this.

So you've got to over-ride DNS using the hosts file for internal
clients:

Or just have them use the internal address. What's the problem with that?
Maybe I missed something.
hosts:
192.168.0.2 www.mydomain.com

Now, external clients get the DNS entry, and connect to the router's
external IP,
but internal clients get the hosts over-ride and connect to the
internal 192.168.0.2 IP.

However, this is more complex because the site is split.
Some pages are hosted externally, and some are hosted internally.
So we need 2 seperate DNS records:

One for the external main homepage, which both Internal and External
clients will use,
and one for the home-hosted pages which can be over-ridden for
internal clients.

Ah. OK.
 
P

Peter Hucker

Because that isn't what hosts does. It maps hostnames to IPs, doesn't
redirect one IP address to another.

I strongly suggest you buy a little gateway/router/firewall appliance, put
it between your DSL modem and your network, and disable ICS. It works a lot
better in general. Keep everyone on the same local (private) IP subnet. Use
a static IP for your server, and DHCP if you like for your workstations.

Windows makes a lousy router, if you ask me -and ICS is dreadful stuff.

It is sharing just fine. And I have an awful phone line - it's very difficult to get an ADSL modem/router to work on it - the one that works happenes to be USB.

Anyway even if I used a router (which I used to), I still have the same problem with a different IP being used for my server from here, than from externally.

--
*****TWO BABY CONURES***** 16 parrots and increasing http://www.petersparrots.com
93 silly video clips http://www.insanevideoclips.com
1259 digital photos http://www.petersphotos.com
Served from a pentawatercooled dual silent Athlon 2.8 with terabyte raid

Lysdexia: a peech imspediment we live to learn with...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top