[GH-ISSUE #37] Is it possible to handle wildcard DNS? #15

Closed
opened 2026-03-04 23:23:44 +03:00 by kerem · 5 comments
Owner

Originally created by @exactsameproblem on GitHub (Oct 24, 2017).
Original GitHub issue: https://github.com/yswery/PHP-DNS-SERVER/issues/37

Hello there,
Awesome project. I'm looking for a fast and easy way to implement a DNS server in PHP, and I would like to handle dynamic wildcard DNS.
I would like to get outputs the following way:
name.subdomain.example.com -> get "name", return xx.xx.xx.xx
name2.subdomain.example.com -> get "name2", return xx.xx.xx.xx
Is it possible to achieve?
Thanks.

Originally created by @exactsameproblem on GitHub (Oct 24, 2017). Original GitHub issue: https://github.com/yswery/PHP-DNS-SERVER/issues/37 Hello there, Awesome project. I'm looking for a fast and easy way to implement a DNS server in PHP, and I would like to handle dynamic wildcard DNS. I would like to get outputs the following way: name.subdomain.example.com -> get "name", return xx.xx.xx.xx name2.subdomain.example.com -> get "name2", return xx.xx.xx.xx Is it possible to achieve? Thanks.
kerem 2026-03-04 23:23:44 +03:00
Author
Owner

@Thiritin commented on GitHub (Jul 24, 2018):

(I think Wildcards are generally not Supported at the moment?)

<!-- gh-comment-id:407517144 --> @Thiritin commented on GitHub (Jul 24, 2018): (I think Wildcards are generally not Supported at the moment?)
Author
Owner

@ivanstan commented on GitHub (Aug 1, 2018):

The "official" way of doing this would be AXFR method which we don't support at the moment. Its commonly used for zone transfers. Here's an example of dig queries:

dig @127.0.0.1 subdomain.example.com axfr

Or wild card domain lookup like this:

dig @127.0.0.1 '*.subdomain.example.com'

We could implement it but this also brings security issues to discussion, we would have to consider to allow/disallow wildcard lookups per domains, or restrict them by client ip.

<!-- gh-comment-id:409568453 --> @ivanstan commented on GitHub (Aug 1, 2018): The "official" way of doing this would be AXFR method which we don't support at the moment. Its commonly used for zone transfers. Here's an example of dig queries: ``` dig @127.0.0.1 subdomain.example.com axfr ``` Or wild card domain lookup like this: ``` dig @127.0.0.1 '*.subdomain.example.com' ``` We could implement it but this also brings security issues to discussion, we would have to consider to allow/disallow wildcard lookups per domains, or restrict them by client ip.
Author
Owner

@Thiritin commented on GitHub (Aug 1, 2018):

@ivanstan thanks for the response. Its currently the only function that prevents this software to be used in production. As Wildcards are required for many purposes.

What Security Issues do come with it?

<!-- gh-comment-id:409648463 --> @Thiritin commented on GitHub (Aug 1, 2018): @ivanstan thanks for the response. Its currently the only function that prevents this software to be used in production. As Wildcards are required for many purposes. What Security Issues do come with it?
Author
Owner

@ivanstan commented on GitHub (Aug 1, 2018):

Hey, I played a little and managed to make a server return wildcard response on my fork https://github.com/ivanstan/PHP-DNS-SERVER/tree/master, but am not happy with the code and it requires a lot of testing and refactor. So keep in mind that this is just proof of concept. So starting server on this branch like this:

sudo php example.php

and running query:

dig @127.0.0.1 *.test.com

will produce following answer:

; <<>> DiG 9.9.7-P3 <<>> @127.0.0.1 *.test.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8836
;; flags: qr rd ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; MBZ: 012c , udp: 4096
;; QUESTION SECTION:
;*.test.com.			IN	A

;; ANSWER SECTION:
a.test.			300	IN	A	111.111.111.222
b.test.			300	IN	A	222.222.222.222

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Aug 01 20:37:07 CEST 2018
;; MSG SIZE  rcvd: 83

I hope that's what are you looking for.

@yswery haven't heard months from you, maybe you could give me push permissions again if you don't have time to deal with this, I would like to setup those tagged releases and merge some new features into dev.

<!-- gh-comment-id:409679254 --> @ivanstan commented on GitHub (Aug 1, 2018): Hey, I played a little and managed to make a server return wildcard response on my fork https://github.com/ivanstan/PHP-DNS-SERVER/tree/master, but am not happy with the code and it requires a lot of testing and refactor. So keep in mind that this is just proof of concept. So starting server on this branch like this: ``` sudo php example.php ``` and running query: ``` dig @127.0.0.1 *.test.com ``` will produce following answer: ``` ; <<>> DiG 9.9.7-P3 <<>> @127.0.0.1 *.test.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8836 ;; flags: qr rd ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; MBZ: 012c , udp: 4096 ;; QUESTION SECTION: ;*.test.com. IN A ;; ANSWER SECTION: a.test. 300 IN A 111.111.111.222 b.test. 300 IN A 222.222.222.222 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Wed Aug 01 20:37:07 CEST 2018 ;; MSG SIZE rcvd: 83 ``` I hope that's what are you looking for. @yswery haven't heard months from you, maybe you could give me push permissions again if you don't have time to deal with this, I would like to setup those tagged releases and merge some new features into dev.
Author
Owner

@samuelwilliams commented on GitHub (Oct 6, 2018):

I have added this to the latest build of branch version-1. b594ec006b

<!-- gh-comment-id:427530969 --> @samuelwilliams commented on GitHub (Oct 6, 2018): I have added this to the latest build of branch version-1. b594ec006b2b3f6333976f99e7de66e93dfc42ec
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/PHP-DNS-SERVER#15
No description provided.