Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Webserver acting strangely - suspect hosts file?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
birkinshawc
n00b
n00b


Joined: 28 Apr 2004
Posts: 11

PostPosted: Sun May 29, 2005 1:02 pm    Post subject: Webserver acting strangely - suspect hosts file? Reply with quote

When I navigate to "www.mydomain.org.uk/somepage" the browser seems to forward to "gateway.mydomain.org.uk/somepage" which seems odd. My hostname for this PC is "gateway" as it is used for web/email/firewall duties. My hosts file contains:

127.0.0.1 localhost
192.168.1.1 gateway.mydomain.org.uk gateway mydomain.org.uk

I guess I could change the name here from gateway to www, but then this wouldn't be very appropriate for sending emails. What is the best solution to this problem?

I am also a little confused by CNAME records. My A record points to mydomain.org.uk, and I have a CNAME record for www.mydomain.org.uk which points to mydomain.org.uk. I don't have a CNAME record for gateway.mydomain.org.uk though... How should this all be setup?

Many thanks,

Chris
Back to top
View user's profile Send private message
adaptr
Watchman
Watchman


Joined: 06 Oct 2002
Posts: 6730
Location: Rotterdam, Netherlands

PostPosted: Sun May 29, 2005 2:06 pm    Post subject: Reply with quote

Don't point just the domain name to your IP - set up real DNS if you have such needs.

What do you mean, "my CNAMEs" ?
Do you run this nameserer, or does somebody else ?

As to how to set this up, that's quite simple.

- a mail server may not be a CNAME; point it to an actual IP.
- if you serve DNS for this domain to the outside world you also need an MX record that points to your mail server name; this is the main reason why the mail server name may not be a CNAME.
_________________
>>> emerge (3 of 7) mcse/70-293 to /
Essential tools: gentoolkit eix profuse screen
Back to top
View user's profile Send private message
birkinshawc
n00b
n00b


Joined: 28 Apr 2004
Posts: 11

PostPosted: Sun May 29, 2005 7:34 pm    Post subject: Reply with quote

adaptr wrote:
Don't point just the domain name to your IP - set up real DNS if you have such needs.


Can you explain what you mean by this? I'm still not sure why apache is redirecting me to gateway.xxxx and not leaving it at www.xxxx. Would I have to change the hostname of the server to "www" for this to work?

NB: This redirect still happens if I access my webpages from inside my LAN, so must be related to the hosts file (I use DNSmasq on the server to serve DNS to my LAN).


Quote:

What do you mean, "my CNAMEs" ?
Do you run this nameserer, or does somebody else ?



The DNS is managed by a proper provider and not myself, as is my MX backup.

At the moment my A name points to my IP, as does my MX Record. I have C name entires for www.mydomain.org.uk, but not for gateway.mydomain.org.uk, so wondered how the browser can even go to gateway.mydomain.org.uk at all. If the browser can go to gateway.mydomain.org.uk without a C name entry for this then why does my provider say I should have an entry for www.mydomain.org.uk - surely it would work without taking the previous example into account?
Back to top
View user's profile Send private message
adaptr
Watchman
Watchman


Joined: 06 Oct 2002
Posts: 6730
Location: Rotterdam, Netherlands

PostPosted: Sun May 29, 2005 9:44 pm    Post subject: Reply with quote

birkinshawc wrote:
adaptr wrote:
Don't point just the domain name to your IP - set up real DNS if you have such needs.

Can you explain what you mean by this?

Sure.
The hosts file is most happy when you input lines in this format:
Code:
<IP address> <FQDN> <alias>

Very important to put the fqdn before the hostname here!
That is, unless you run a nameserver on your LAN.

birkinshawc wrote:
I'm still not sure why apache is redirecting me to gateway.xxxx and not leaving it at www.xxxx. Would I have to change the hostname of the server to "www" for this to work?

No, generally speaking apache's hostname has very little to do with your machine's real hostname; you can do pretty much anything you like with apache.
Of course, if you have not set the ServerName yourself then apache will try to use your hostname.
Always set your own ServerName.

birkinshawc wrote:
NB: This redirect still happens if I access my webpages from inside my LAN, so must be related to the hosts file (I use DNSmasq on the server to serve DNS to my LAN).

Probably is, then.

birkinshawc wrote:
Quote:

What do you mean, "my CNAMEs" ?
Do you run this nameserer, or does somebody else ?

The DNS is managed by a proper provider and not myself, as is my MX backup.

At the moment my A name points to my IP, as does my MX Record.

Then your mail server HAS to answer to this name!
Seriously.
As an aside, many so-called "domain hosting" firms set an IP in the MX record; strictly speaking, the RFCs forbid this; the MX record should always resolve to an A name, which points to an IP.
It should not point to a CNAME, nor directly to an IP address.
Simply put, such companies suck.

You can use another (sub-)domainname internally, e.g. in responses from the server, but its HELO should be exactly what the MX record points to.
Many MTA's do a reverse-DNS check on the HELO these days.

birkinshawc wrote:
I have C name entires for www.mydomain.org.uk, but not for gateway.mydomain.org.uk, so wondered how the browser can even go to gateway.mydomain.org.uk at all. If the browser can go to gateway.mydomain.org.uk without a C name entry for this then why does my provider say I should have an entry for www.mydomain.org.uk - surely it would work without taking the previous example into account?

Because they're sticklers for tradition, probably.
I am betting money they have set up a wildcard forwarding any subdomain not in the zone to your IP.
Because that's easiest for them.

You should
Code:
emerge bind-tools

and familiarise yourself with dig.
You will learn plenty ;-)
_________________
>>> emerge (3 of 7) mcse/70-293 to /
Essential tools: gentoolkit eix profuse screen
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum