Comments (2)
Comments from old bug system.. I have played with this patch and found that there are a few issues with it. Its currently in the code repository but just commented out. more to be done/tested here.
One thing I found was that you can use '-' instead of '/' as the delimiter. http://www.zytrax.com/books/dns/ch3/
I'm inclined to do it that way for now because it opens up possible problems for other names that use the sanitize_hostname function. That function really needs to be updated so you can pass in a type so it can deal with the various rules for the different resource records that behave differently.
Another issue I have found relates to how ONA determines which PTR domain to put records into. I need to update that bit of code to handle things properly if you had the following 3 domains as an example:
0-27.23.168.192.in-addr.arpa
64-27.23.168.192.in-addr.arpa
23.168.192.in-addr.arpa
Also I think the update to the build_bind will need to deal with more than the last digit if someone was using the more encompassing PTR domains like 168.192.in-addr.arpa for example. There is similar code in some of the display record code I think that can be used.
Anyway.. looks like a good feature to add. I'll start getting things incorporated.
Comment by Alex Kabakaev (synapse) - Monday, 27 September 2010, 18:26 GMT
Matt,
True, if we have more than one CIDR subnet, a problem rise. Here is the solution for that case.
Function ona_find_domain() was modified.
Flyspray editor eats whitespaces, so take the patch: http://netserver.chtd.tpu.ru/ona_diff/functions_db.inc.php-v10.05.27-CIDR.patch
The same, just in case.
$ diff functions_db.inc.php-v10.05.27 functions_db.inc.php
1672a1673,1702
>
> if ($status == 0 and $parts[0] === "arpa") { // check the PTR domain for classless (CIDR) subnet that suits the ip, for example ip=192.168.1.2, domain=0/25.1.168.192.in-addr.arpa
> $ip = implode('.', $parts); // now we have something like arpa.in-addr.192.168.1.2
> $ip = str_replace("arpa.in-addr.", '', $ip); // get pure ip, for example 192.168.1.2. We gonna find a subnet for this ip
> list($localPart, $parent_domain) = explode('.', $fqdn,2); // taking the parent domain name, i.e. 1.168.192.in-addr.arpa
> list($exit_status, $number_of_rows, $record) = ona_get_domain_record("name LIKE '%.{$parent_domain}'"); // grab classless sub-domains. Example: 0/25.1.168.192.in-addr.arpa
> $i=0;
> while($i < $number_of_rows) { // walk through all subdomains
> $i++;
> list($subnet_def, $class_subnet) = explode('.', $record['fqdn'], 2); // get subnet defenition, i.e. $subnet_def='0/25', and $class_range=1.168.192.in-addr.arpa
> $split_characters = '\/\-'; // subnet defenition symbols. Currently '/' or '-' can be used
> if (1 == preg_match("/(\d+)[$split_characters](\d+)/", $subnet_def, $matches)) { // yes, we have a CIDR. Let's check if ip is within this CIDR
> $subnet = $matches[1]; // here we pop '0' (last octet of the ip range) from '0/25' string
> $subnet = implode('.', array_reverse(explode('.', $class_subnet)) ) . $subnet; // now we have something like arpa.in-addr.192.168.1.0
> $subnet = str_replace("arpa.in-addr.",'',$ip); // finally we have normal subnet 192.168.1.0
> $subnet_dec = ip2long($subnet); // convert 192.168.1.0 to its decimal representation
> $ip_dec = ip2long($ip); // the same for IP
> $netmask = $matches[2]; // get the netmask length, i.e. '25'
> printmsg("DEBUG => ona_find_domain({$fqdn}). Subnet: {$subnet} Netmask: {$netmask} Matches: ".var_export($matches,true), 3);
> $wildcard_dec = pow(2, (32-$netmask)) - 1;
> $netmask_dec = ~ $wildcard_dec; // decimal netmask
> if (($ip_dec & $netmask_dec) == ($subnet_dec & $netmask_dec)) { // check if both ip and subnet are within the netmask
> $domain = $record;
> printmsg("DEBUG => ona_find_domain({$fqdn}) Found: {$domain['fqdn']}", 3);
> }
> }
> list($exit_status, $number_of_rows, $domain) = ona_get_domain_record("name LIKE '%.{$parent_domain}'"); // get the next row
> }
> }
>
from ona.
As of now I'm closing this issue. This functionality is effectively in both ONA and build_bind. If you create a delegated PTR domain within ona by naming it something like 0-25.161.123.192.in-addr.arpa you will get proper delegation records. I'm using the '-' character delineation instead of '/' as it fits better within the current functions and syntax checking.
from ona.
Related Issues (20)
- PHP Fatal error: Cannot unset $this HOT 2
- Deprecated: Methods on PHP 7 HOT 1
- Adding DHCP options doesn't worka (anymore?) HOT 8
- rndc.key HOT 1
- DNS Server Entries Error with MariaDB >= 10.2 HOT 2
- Split dns; internal A local record with rest of the domain resolved via global forward? HOT 3
- Valid IPv6 subnet masks not allowed HOT 2
- /etc/onabase: Permission denied HOT 1
- Build_dns creates unusable ptr records
- build_bind ignores dns_views?
- Apache2 error on Ubuntu 21.10 HOT 4
- upgrade issue HOT 15
- dcm.pl throws error when getting empty custom_attribute_display list
- Custom Attribute modify changes the type to the last one of the list HOT 4
- Can't create CNAME record HOT 6
- LDAP authentication failed with 'Unknown User' HOT 9
- dcm.pl uses with local user
- Reverse-proxy issues HOT 1
- User groups disappear while upgrading to v19.0.0 HOT 3
- Automatically updating dhcpd.conf.ona and named.conf.ona
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ona.