Nameserver Lookup Tool
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background-color: #f4f7fa;
color: #333;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
header {
text-align: center;
margin-bottom: 30px;
}
header h1 {
font-size: 2.5rem;
color: #4CAF50;
}
header p {
font-size: 1.2rem;
color: #555;
}
main {
text-align: center;
}
form {
margin-bottom: 20px;
}
input {
padding: 10px;
font-size: 1rem;
width: 70%;
max-width: 400px;
border: 2px solid #4CAF50;
border-radius: 5px;
margin-right: 10px;
}
button {
padding: 10px 20px;
font-size: 1rem;
background-color: #4CAF50;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
#loader {
display: none;
margin: 20px auto;
border: 8px solid #f3f3f3;
border-top: 8px solid #4CAF50;
border-radius: 50%;
width: 50px;
height: 50px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
#result {
margin-top: 30px;
display: none;
text-align: left;
}
#result h3 {
font-size: 1.5rem;
color: #4CAF50;
}
#nameserverList {
list-style-type: none;
padding-left: 0;
}
#nameserverList li {
background-color: #fff;
padding: 10px;
margin: 10px 0;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
footer {
text-align: center;
margin-top: 40px;
font-size: 0.9rem;
}
footer p {
color: #555;
}
@media (max-width: 600px) {
input {
width: 90%;
}
}
document.getElementById('lookupForm').addEventListener('submit', function (event) {
event.preventDefault();
const domain = document.getElementById('domain').value.trim();
if (domain) {
lookupNameservers(domain);
}
});
async function lookupNameservers(domain) {
const loader = document.getElementById('loader');
const resultContainer = document.getElementById('result');
const nameserverList = document.getElementById('nameserverList');
// Clear previous results and hide the results section
nameserverList.innerHTML = '';
resultContainer.style.display = 'none';
loader.style.display = 'block';
try {
const response = await fetch(`https://dns.google/resolve?name=${domain}&type=NS`);
const data = await response.json();
loader.style.display = 'none';
if (data.Answer) {
resultContainer.style.display = 'block';
data.Answer.forEach((answer) => {
const listItem = document.createElement('li');
listItem.textContent = answer.data;
nameserverList.appendChild(listItem);
});
} else {
showError('No nameservers found or invalid domain.');
}
} catch (error) {
loader.style.display = 'none';
showError('An error occurred while fetching nameservers.');
}
}
function showError(message) {
const resultContainer = document.getElementById('result');
resultContainer.style.display = 'block';
resultContainer.innerHTML = `
${message}
`;
}