Quick DNS Check

Last week I had to install a WordPress network (50 IP + 50 NDD) with domain mapping, and I was faced with a vicious problem.

Indeed, the domain names all had a completely different DNS configuration, .fr, old domain, parked domain, domain pointing to another hosting, their only common point was to be all registered to OVH.

There I said cool, I will be able to do all of a sudden, but at OVH we do not practice Bulk Action 🙁

So I started to check the DNS configurations of the domain names one by one (twitting at the same time because eh!) And I realized that a few had the right configuration.

To save time, I, therefore, looked in the doc PHP a magic trick and I found “dns_get_record.” I said to myself without it will spare me at ease 150 clicks, too bad if I spend, I’m sure I’ll get back to you, and I’ll know where to go.

So here’s a bit of code that will allow you to quickly check the HTTP status and DNS (actually the A field and NS fields only) of a domain list.

If you do not have a WPMU to install with domain mapping, you can always use this tool to check if your sites are accessible and disconnected 😉

I pass my hand to Bertimus, thank you for this tribute!

Beunwa, breeder of bots

PS: I thought about feigning, you can put deep pages with or without HTTP in the interface work anyway.
PS2: If you do not have php5 or phpcurl it will work much less well (in fact it will not work at all)
PS3: Bertimus provides support: D

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html PUBLIC “-//W2C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w2.org/1999/xhtml” dir=”ltr” lang=”fr-fr”>
<head profile=”http://gmpg.org/xfn/11″>

<title>Quick Dns Check</title>
</head>
<body>
<?php
function getUrl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
$res = curl_exec( $ch );
$info = curl_getinfo($ch);
$error = curl_error($ch);

$pattern = “#META http-equiv=[‘|\”]Refresh[‘|\”] content=[‘|\”][0-9]+;url=(.*?)[‘|\”]#si”;
if(preg_match($pattern, $res, $loc)) {
$url = $loc[1];
}else{
$url = $info[‘url’];
}
/*if(stristr($theRes, ‘XML-RPC server accepts POST requests only.’))*/ return array($res, $info, $url, $error);
}
if(isset($_POST[‘txt’])){
$tab = preg_split(‘#(\n)#’,$_POST[‘txt’]);
foreach($tab as $u){
$u = trim($u);
if(substr($u, 0, 4) != ‘http’) $u = ‘http://’.$u;
$u = parse_url($u);
$url = $u[scheme].’://’.$u[host];
$proc = getUrl($url);
$status = $proc[1][‘http_code’];
echo ‘<br /><br />’.$u[host];
$dnscheck = dns_get_record($u[host], DNS_A + DNS_NS);
if(count($dnscheck) == 0){
echo ‘<br />Allo Houston on a un gros problème. AUCUN enregistrement DNS<br />’;
echo ‘Si c\’est un domaine en .fr il faut regarder du coté de l\’AFNIC, dans tous les cas du coté de votre registrar<br /><br />’;
continue;
}
if($status != 200){
echo ‘ : code http : ‘.$status.’ ‘.$proc[3].'<br />’;
if(count($dnscheck) > 0) echo ‘<br />Si l\’ip A vous semble valide alors il va vous falloir chercher du coté de la configuration de votre serveur WEB<br /><br />’;
//print_r($dnscheck);
}
foreach($dnscheck as $d){
$type = $d[type];
echo ‘<br /><b>’.$type.'</b> ‘;
if($type != ‘A’) echo $d[target];
else echo $d[ip];
}
}
}

?>
<h1>Quick Dns Check</h1>
<p>Collez votre liste d’url dans le champ texte ci-dessous et cliquez sur Go (homepages ou page profonde avec ou sans http)</p>
<form action=”” method=”post”>
<textarea name=”txt” style=”width:300px;height:300px;”><?php echo $rt; ?></textarea>
<input type=”submit” value=”Go” />
</form>
</body>
</html>

Related Video: