PDA

View Full Version : Found small bug in DirectAdmin in DNS/nameserver setup



Aspegic
04-26-2006, 12:37 PM
I found a small bug in DirectAdmin while researching a problem a user had posted in this forum.

How to reproduce the problem:

Only a single IP address is assigned to the server (e.g. the IP Manager only shows 1 IP address).

Go to the reseller level, click 'Nameservers', select the IP address and click the "Create" button. (The control panel allows this even though only one IP address is selected.)

This will result in a corrupted zone file, like this:

This is how it looks in DNS Administration

ftp A 66.51.122.131
localhost A 127.0.0.1
mail A 66.51.122.131
ns1.domain.com. A 66.51.122.131
ns2.domain.com. A pop 14400 IN A 66.51.122.131
domain.com. A 66.51.122.131
www A 66.51.122.131
domain.com. NS ns1.domain.com.
domain.com. NS ns2.domain.com.
mail MX 10
domain.com. TXT "v=spf1 a mx ip4: ?all"

This is the resulting domain.com.db file

$TTL 14400
@ IN SOA ns1.domain.com. root.domain.com. (
2006042601
7200
3600
1209600
86400 )
domain.com. 14400 IN NS ns1.domain.com.
domain.com. 14400 IN NS ns2.domain.com.
ftp 14400 IN A 66.51.122.131
localhost 14400 IN A 127.0.0.1
mail 14400 IN A 66.51.122.131
ns1.domain.com. 14400 IN A 66.51.122.131
ns2.domain.com. 14400 IN A
pop 14400 IN A 66.51.122.131
domain.com. 14400 IN A 66.51.122.131
www 14400 IN A 66.51.122.131
domain.com. 14400 IN MX 10 mail
domain.com. 14400 IN TXT "v=spf1 a mx ip4: ?all"


So either DirectAdmin should not allow the user to create nameservers if only 1 IP address is selected, or, preferably, create only a single nameserver with the selected IP address.

I understand that this is a user error. Afterall this feature is designed to work with 2 IP addresses. Nevertheless some users will try it with just a single IP address and that should not result in a corrupted zone file.

nobaloney
04-26-2006, 06:03 PM
Perhaps DA should create both nameservers with the same IP# under this circumstance.

Many registrars allow two nameservers on the same IP#.

It would actually work for a lot of admins, and it's no less robust than using two IP#s on the same server.

Jeff

DirectAdmin Support
04-26-2006, 10:03 PM
Hello,

Thanks for that report.
For the next release, I've changed it to check for ip2.. if ip1 was passed and ip2 wasn't, then use ip1 for ns2 as well.

John

Aspegic
04-26-2006, 11:19 PM
You may also want to peek at the code behind the "Delete Nameservers" button. I'm just saying, because I was unable to correct this problem through the control panel. I had to manually edit the db and 66.51.122.131 files.
Adding a temporary 'dummy' second IP address would not let me correct the problem either. If I selected both for deletion it would report that I need to select two nameserver IP's, if I first tried to create a second ns with the dummy one it would complain I need to select 2 first, and if I selected both it would complain that one already had a ns assigned to it :)

I agree with Jeff's solution (creating both ns1 and ns2 with the single IP address).
I just wonder what will happen if I first edit the two nameserver names text fields and enter "ns1" into both of them. Will it create two records both with ns1 or will it detect this and only create a single one (eg. if (ns1namefield == ns2namefield) { create only 1 ns record } ). That way both options would be possible (creating a single ns with the one ip or creating two as jeff suggested).

While on this subject I have a small feature request (at least I think it's small):

In the bottom-half of the 'Nameservers' setup screen, would it be possible to add a third "Name Server 3" field to be automatically assigned to new users? This field would just be empty initially but if a ns is entered there it would also be assigned to new useraccounts.

Thanks!