Re: [Dorset] Using the host file

2013-05-24 Thread Andrew Morgan

On 23/05/2013 17:16, Tim wrote:

So I edited the /etc/host file as follows


Do you mean '/etc/hosts'?
It seems from a later post that your ping looked up the correct IP 
address, so presumably you did edit the correct file, but I thought it 
would be worth checking.


--

Andrew.



--
Next meeting:  Bournemouth, Tuesday, 2013-06-04 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread on mailing list:  mailto:dorset@mailman.lug.org.uk
How to Report Bugs Effectively:  http://goo.gl/4Xue


Re: [Dorset] Using the host file

2013-05-24 Thread Ralph Corderoy
Hi Tim,

Starting from the beginning because I have a little more time...

 I am trying to access a web site via a different IP address than the
 normal web site sits on. I have been told (by the owners of the the
 web site) to add an IP address to my host file which resolve to the
 domain name. So I edited the /etc/host file as follows
 
 1.1.1.1 thesite.co.uk (all fictitious, just an example)

 I then saved it and restarted the networking.

No need to re-start networking.  /etc/hosts is read by the program
you're running, e.g. the browser or ping.

sudo strace -e open ping -c 1 google.com

Re-starting the browser would do in case it remembered it couldn't find
thesite.co.uk from your previous attempts.

 I then tested the access to the web site and while I could access the
 web site I am unable to access the bit of the web site that I need to
 access which the above mod to the host file should of let me access.

I see what the owners want you to do and why but don't know if
thesite.co.uk is already known, e.g. through DNS, and you're trying to
override it or whether it's unknown and yours is the only definition
visible.  If the former then your browser may have been using the old
public definition and if there's two different IP addresses, public and
private, serving apparently the same site but with extras on private,
you may not obviously know which you're accessing.

I understand why we can't know the details but it makes investigation
awkward.  :-)

 If I ping the web site it comes back saying
 
 ping website.co.uk (1.1.1.1) 56(84) bytes of data
 (where 1.1.1.1 is the ip address I put in the host file).

That's good.

 When I do the tcpdump -i any -n port 80 (I only have the website.co.uk
 on a single tab in the browser) I get a lot of traffic between my PC
 and an NTL server (which I would expect as I am on Virgin) but out of
 some 40 odd lines it produces as I change page on the web site it is
 only those two IP addresses that it shows.

Is your browser configured to use an NTL proxy in some way?  What if you
repeat the test but have google.com as the single tab;  is it still the
NTL server?  Could that be interfering?

 Martin Hepworth wrote:
  Also make sure 'file' is mentioned before dns in the hosts line
  within /etc/resolv.conf

 My resolv.conf only has one line (unhased line)
 
 nameserver 127.0.1.1

Yes, I think Martin meant /etc/nsswitch.conf and/or /etc/host.conf, as
shown by that strace of ping above.  You can check if your /etc/hosts
line is having an effect by pinging thesite.co.uk with the line there
and without it.  The IP address should change if you line is having an
effect and there is any point having it.  Mine, for example, has `files'
first.

$ grep -w hosts /etc/nsswitch.conf /etc/host.conf
/etc/nsswitch.conf:hosts:  files mdns4_minimal [NOTFOUND=return] 
dns mdns4
/etc/host.conf:order hosts,bind
$ 

  You could pass an explicit Host header just to check the server is
  configured as you expect.  As an example, try
 
   curl -sSvIH 'Host: dorset.lug.org.uk' http://google.com/
 
 I assume you wanted me to replace google.com with the web site I am 
 trying to access

Nope!  :-)  Sorry, I thought you knew how this worked under the covers
and that a means of testing the remote server without involving a
browser might be useful.

Let's say 1.2.3.4 is the IP address you've been told to contact when
your enter http://thesite.co.uk/foo/bar in the browser.  Do

curl -sSvIH 'Host: thesite.co.uk' http://1.2.3.4/foo/bar

This tells curl to access 1.2.3.4 and ask it in the HTTP protocol for
the headers of /foo/bar on the thesite.co.uk website.  /foo/bar could be
either a public part everyone can reach or private.

Cheers, Ralph.

-- 
Next meeting:  Bournemouth, Tuesday, 2013-06-04 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread on mailing list:  mailto:dorset@mailman.lug.org.uk
How to Report Bugs Effectively:  http://goo.gl/4Xue