Web Hosting Talk







View Full Version : Is this possible ?


xaero
03-07-2008, 10:35 PM
I have a script for the linux servers that i have at various businesses that I admin. I have a web link that the servers wget each hour and it sends its unique name to the server. The server then inserts the $_SERVER['REMOTE_ADDR'] into a mysql database if the unique id is valid .... my question

is there anyway it have bind create host (A) records for each of the unique names and use the ip addresses in the database?
the table structure is
id | name | ip
1 server1 000.000.000.000

so is there any way to get the the data out of the database and into bind?

deseek
03-08-2008, 09:41 PM
Not too sure exactly what you mean, but it sounds like you be able to do all of that from a BASH shell script if you have shell access to the server as long as you know all of the commands to do it manually.

mysql -u username -ppassword -D dbname -e "SELECT name,ip FROM tablename"

would return the output to the shell
You could also do that from a Perl or PHP script run in the shell. It would be easier using them as they allow easier access to mysql databases.

xaero
03-08-2008, 10:56 PM
yes im currently using
#!/bin/bash
echo "Updating HOSTS file..."
cat /root/hosts > /etc/hosts
mysql -ujustin -p******** -h********** -e "use server; SELECT ip, server$
echo "HOSTS File Updated"

to update my laptops host file... but i want to use by dns server and make each of the hosts a record on there so ...when the database returns the info
say

1.2.3.4 server1
5.6.7.8 server2

server1.mydomain.com = 1.2.3.4
server2.mydomain.com = 5.6.7.8


and this is my server (colocated) so i have full access to whatever i need just not 100% sure how todo it

bqinternet
03-09-2008, 07:31 AM
It's a simple matter of writing a script to generate the BIND zone file, and then send a HUP signal to the BIND process to have it reread the configuration.

Xeentech
03-10-2008, 08:05 AM
I've done stuff like this before and it is a pain.

Problems / Annoyances I ran into

Script has to make BIND reload the conf file and zones, may need root access to do this depending on the setup
BIND zone files are needlessly complex syntax wise and easy to break
User's will submit invalid data and break the config
User's will duplicate data, and BIND will prefer the first answer it finds
Parsing the BIND Zone and conf back into your script it painful


As a solution I setup BIND with only my main domain's zone and had to recursivly lookup the other zones from a MyDNS (http://mydns.bboy.net/) daemon.

The MyDNS looks up zones and then records from tables in a MySQL (or other) DBMS.

If one zone of record is invalid it only effects that record.
Doesn't require root privalages to restart it
You don't need to duplicate data, you can re-read zones from the same db, rather than parsing a Zone file