Gamecommunity =GCHQ=
http://82.148.227.125:8080/

php
http://82.148.227.125:8080/viewtopic.php?f=122&t=36452
Page 1 of 1

Author:  happyslappy [ Fri Dec 15, 2006 5:36 pm ]
Post subject:  php

im kinda stuck using this
$dnsip = gethostbyname($feature_name);
works for full dns name but fails on for example nagios

on the same machine though i have the search paths added
horizon:/var/www/ops-ssl/datacentre# more /etc/resolv.conf
search search its.manchester.ac.uk mcc.ac.uk mc.man.ac.uk fin.manchester.ac.uk sdt.manchester.ac.uk ds.man.ac.uk
nameserver use domain.200.6
nameserver use domain.203.17
nameserver use domain.203.7
nameserver use domain.200.2

so
horizon:/var/www/ops-ssl/datacentre# nslookup nagios
Server: use domain.200.6
Address: use domain.200.6#53

Name: nagios.its.manchester.ac.uk
Address: use domain.249.4

returns the correct IP

why dose it fail in php ?

Author:  Chips=GCHQ= [ Sat Dec 16, 2006 12:00 pm ]
Post subject: 

I remember trying this and never getting it working, but i didn't really try to solve the issue.

Take it you've looked through the comments at http://us2.php.net/manual/en/function.gethostbyname.php

Those are usually the best place to start with tracking down issues in php functions, as often folks find a solution years before you have a problem :P

Author:  Arma [ Sat Dec 16, 2006 5:51 pm ]
Post subject: 

Maybe it would be because the manual says that it should be a fully qualified domain name, whereas your local DNS client will search your local network.

Maybe a good solution would be to detect if the submitted variable has a '.' in it and if it dosent then to append the local networks on to the end and surch through them in turn.

Author:  happyslappy [ Sat Dec 16, 2006 7:34 pm ]
Post subject:  cheers

cheers - unfortuanly we have around 100 diff dns domains/sub domains to check but i never thought of doing this
<?php
$ip = rtrim(`/usr/bin/dig $host A +short`);
?>

it will solve 80% of me problems untill i hit and example like a machine slappy

slappy.mc.man.ac.uk
see slap
slappy.its.manchester.ac.uk
slappy.umist.ac.uk
etc etc

all diff machines - this is just a example but i know loads that will do this

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/