ameshkov / dnslookup

Simple command line utility to make DNS lookups to the specified server
MIT License
816 stars 72 forks source link

[Windows] invalid IP specified: SUBNET=1.2.3.4/24 or HTTP3=1 #58

Closed Odyssey-2061 closed 10 months ago

Odyssey-2061 commented 10 months ago

All works when query with basic feature:

PS C:\Users\kldac> dnslookup www.tiktok.com 208.67.222.222
dnslookup v1.10.0
Server: 208.67.222.222

dnslookup result (elapsed 36.0885ms):
;; opcode: QUERY, status: NOERROR, id: 20377
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.tiktok.com.        IN       A

;; ANSWER SECTION:
www.tiktok.com. 187     IN      A       168.143.171.189

But I'm going to get error code when query with extra options:

SUBNET

PS C:\Users\kldac> SUBNET=1.2.3.4/24 dnslookup example.org tls://8.8.8.8
SUBNET=1.2.3.4/24: The term 'SUBNET=1.2.3.4/24' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

or

PS C:\Users\kldac> dnslookup example.org tls://8.8.8.8 SUBNET=1.2.3.4/24
dnslookup v1.10.0
2023/11/01 16:21:51 [fatal] invalid IP specified: SUBNET=1.2.3.4/24

HTTP3

PS C:\Users\kldac> HTTP3=1 dnslookup example.org https://dns.google/dns-query
HTTP3=1: The term 'HTTP3=1' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

or

PS C:\Users\kldac> dnslookup example.org https://dns.google/dns-query HTTP3=1
dnslookup v1.10.0
2023/11/01 16:22:43 [fatal] invalid IP specified: HTTP3=1

So how to use extra features on Windows (11)?

ameshkov commented 10 months ago

On Windows the way you pass env variables is a bit different.

Try this:

cmd /V /C "set SUBNET=1.2.3.4/24 && dnslookup example.org tls://8.8.8.8"
Odyssey-2061 commented 10 months ago

On Windows the way you pass env variables is a bit different.

Try this:

cmd /V /C "set SUBNET=1.2.3.4/24 && dnslookup example.org tls://8.8.8.8"

yes there's no error. But I found SUBNET not working.

the output is 36.155.132.31 when SUBNET=1.2.3.4/24:

PS C:\Users\kldac> set SUBNET=1.2.3.4/24 && dnslookup www.baidu.com tls://223.5.5.5
dnslookup v1.10.0
Server: tls://223.5.5.5

dnslookup result (elapsed 143.9065ms):
;; opcode: QUERY, status: NOERROR, id: 49136
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version 0; flags:; udp: 4096

;; QUESTION SECTION:
;www.baidu.com. IN       A

;; ANSWER SECTION:
www.baidu.com.  102     IN      CNAME   www.a.shifen.com.
www.a.shifen.com.       102     IN      A       36.155.132.31
www.a.shifen.com.       102     IN      A       36.155.132.55

It is still 36.155.132.31 when SUBNET=114.114.114.114/24:

PS C:\Users\kldac> set SUBNET=114.114.114.114/24 && dnslookup www.baidu.com tls://223.5.5.5
dnslookup v1.10.0
Server: tls://223.5.5.5

dnslookup result (elapsed 111.6443ms):
;; opcode: QUERY, status: NOERROR, id: 7000
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version 0; flags:; udp: 4096

;; QUESTION SECTION:
;www.baidu.com. IN       A

;; ANSWER SECTION:
www.baidu.com.  83      IN      CNAME   www.a.shifen.com.
www.a.shifen.com.       83      IN      A       36.155.132.55
www.a.shifen.com.       83      IN      A       36.155.132.31

Another example with Quad9 EDNS version:

SUBNET=1.2.3.4/24 for www.paypal.com

PS C:\Users\kldac> set SUBNET=1.2.3.4/24 && dnslookup www.paypal.com tls://9.9.9.11
dnslookup v1.10.0
Server: tls://9.9.9.11

dnslookup result (elapsed 827.008ms):
;; opcode: QUERY, status: NOERROR, id: 23216
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.paypal.com.        IN       A

;; ANSWER SECTION:
www.paypal.com. 3600    IN      CNAME   www.glb.paypal.com.
www.glb.paypal.com.     300     IN      CNAME   paypal-dynamic.map.fastly.net.
paypal-dynamic.map.fastly.net.  300     IN      A       151.101.129.21
paypal-dynamic.map.fastly.net.  300     IN      A       151.101.65.21
paypal-dynamic.map.fastly.net.  300     IN      A       151.101.1.21
paypal-dynamic.map.fastly.net.  300     IN      A       151.101.193.21

same result when SUBNET=114.114.114.114/24 for www.paypal.com

PS C:\Users\kldac> set SUBNET=114.114.114.114/24 && dnslookup www.paypal.com tls://9.9.9.11
dnslookup v1.10.0
Server: tls://9.9.9.11

dnslookup result (elapsed 6.0804351s):
;; opcode: QUERY, status: NOERROR, id: 1454
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;www.paypal.com.        IN       A

;; ANSWER SECTION:
www.paypal.com. 1697    IN      CNAME   www.glb.paypal.com.
www.glb.paypal.com.     297     IN      CNAME   paypal-dynamic.map.fastly.net.
paypal-dynamic.map.fastly.net.  297     IN      A       151.101.65.21
paypal-dynamic.map.fastly.net.  297     IN      A       151.101.193.21
paypal-dynamic.map.fastly.net.  297     IN      A       151.101.1.21
paypal-dynamic.map.fastly.net.  297     IN      A       151.101.129.21
Odyssey-2061 commented 10 months ago

On Windows the way you pass env variables is a bit different.

Try this:

cmd /V /C "set SUBNET=1.2.3.4/24 && dnslookup example.org tls://8.8.8.8"

If I typed cmd /V /C "set SUBNET=1.2.3.4/24 && dnslookup example.org tls://8.8.8.8"then

C:\Users\kldac>cmd /V /C "set SUBNET=1.2.3.4/24 && dnslookup example.org tls://8.8.8.8"
2023/11/01 20:20:49 [info] invalid SUBNET 1.2.3.4/24 : invalid CIDR address: 1.2.3.4/24
Usage: dnslookup <domain> <server> [<providerName> <serverPk>]
<domain>: mandatory, domain name to lookup
<server>: mandatory, server address. Supported: plain, tls:// (DOT), https:// (DOH), sdns:// (DNSCrypt), quic:// (DOQ)
<providerName>: optional, DNSCrypt provider name
<serverPk>: optional, DNSCrypt server public key
ameshkov commented 10 months ago

Sorry, I don't have a Windows laptop to check this.

At some point in the future dnslookup will be rewritten to provide a different command-line interface, it will be better then.

Odyssey-2061 commented 10 months ago

Sorry, I don't have a Windows laptop to check this.

At some point in the future dnslookup will be rewritten to provide a different command-line interface, it will be better then.

Above all, thank you for developing this tool! I'm going to be happy to try futural version!