dnschef icon indicating copy to clipboard operation
dnschef copied to clipboard

Multiple SRV records with different port and target not allowed

Open irsdl opened this issue 5 years ago • 5 comments

I am receiving a record duplicate error when trying to define a SRV record on different ports or to different targets.

Example 1:

_ldap._tcp.dc._msdcs.test123.local=0 50 389 test123.local
_ldap._tcp.dc._msdcs.test123.local=0 50 53 test123.local

Example 2:

_ldap._tcp.dc._msdcs.test123.local=0 50 389 test123.local
_ldap._tcp.dc._msdcs.test123.local=0 50 389 foo.test123.local

Error message is:

Traceback (most recent call last):
  File "dnschef.py", line 516, in <module>
    config.read(options.file)
  File "c:\pythonPath\lib\configparser.py", line 697, in read
    self._read(fp, filename)
  File "c:\pythonPath\lib\configparser.py", line 1093, in _read
    raise DuplicateOptionError(sectname, optname,
configparser.DuplicateOptionError: While reading from '../dnschef.ini' [line 54]: option '_ldap._tcp.dc._msdcs.test123.local' in section 'SRV' already exists

This setting should be allowed and another example can be seen in https://en.wikipedia.org/wiki/SRV_record

Note: I can use the executable version in windows (0.3) and it does not show me any error.

irsdl avatar Jul 21 '20 20:07 irsdl

This issue can be fixed by changing:

config = ConfigParser()

To:

config = ConfigParser(strict=False)

More info: https://docs.python.org/3.4/library/configparser.html

irsdl avatar Jul 21 '20 20:07 irsdl

This issue can be fixed by changing:

config = ConfigParser()

To:

config = ConfigParser(strict=False)

More info: https://docs.python.org/3.4/library/configparser.html

I too have this issue...but using strict=False does not fix it. It merely allows the server to run. But when you query for the SRV with nslookup, only the last record is returned.

Reason The nametodns dictionary https://github.com/iphelix/dnschef/blob/a395411ae1f5c262d0b80d06a45a445f696f3243/dnschef.py#L525
loads SRV records like this: 'SRV': {'_http._tcp.thesprawl.org': '1 5 5070 www.fake1.com'}

It's not possible to express multiple SRV records with same service name using above structure:

[SRV]
; FORMAT: priority weight port target
_http._tcp.thesprawl.org=0 5 5060 www.fake1.com
_http._tcp.thesprawl.org=1 5 5070 www.fake2.com

amard33p avatar Aug 25 '20 06:08 amard33p

Sorry I forgot to comment here, I confirm the above bad behaviour and that's why I am still using the 0.3 version.

irsdl avatar Aug 25 '20 08:08 irsdl

Sorry I forgot to comment here, I confirm the above bad behaviour and that's why I am still using the 0.3 version.

I believe you are referring to this commit.
Even with v 0.3, it only returns the last entry of the [SRV] section only

[SRV]
; FORMAT: priority weight port target
_http._tcp.thesprawl.org=0 5 5060 www.fake1.com
_http._tcp.thesprawl.org=1 5 5070 www.fake2.com
[root@ub18-01:~] nslookup -type=SRV _http._tcp.thesprawl.org
Server:         127.0.0.1
Address:        127.0.0.1#53

_http._tcp.thesprawl.org        service = 1 5 5070 www.fake2.com.

amard33p avatar Aug 25 '20 09:08 amard33p

I ran it once again (windows version 0.3) to see what I did previously, it seems it did only use the last entry as you said!

irsdl avatar Aug 25 '20 16:08 irsdl