yarrick / iodine

Official git repo for iodine dns tunnel
https://code.kryo.se/iodine
ISC License
6.25k stars 507 forks source link

NS response invalid #38

Closed sijanec closed 4 years ago

sijanec commented 4 years ago

Hello!

I launched iodined like this:

# ./iodined -f -c -P pass 10.46.34.1 ovca.ml -p 2053 -n MYIPADDRESS
ALERT! Other dns servers expect you to run on port 53.
You must manually forward port 53 to port 2053 for things to work.
Opened dns0
Setting IP of dns0 to 10.46.34.1
Setting MTU of dns0 to 1130
Opened IPv4 UDP socket
Opened IPv6 UDP socket
Listening to dns for domain ovca.ml

and then issued a dig command like this:

$ dig ovca.ml -t NS @127.0.0.1 -p 2053

; <<>> DiG 9.11.5-P4-5.1+deb10u1-Debian <<>> ovca.ml -t NS @127.0.0.1 -p 2053
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48883
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;ovca.ml.           IN  NS

;; ANSWER SECTION:
ovca.ml.        3600    IN  NS  ns.ovca.ml.

;; ADDITIONAL SECTION:
ns.ovca.ml.     3600    IN  A   2.0.0.0

;; Query time: 0 msec
;; SERVER: 127.0.0.1#2053(127.0.0.1)
;; WHEN: Wed Jul 22 23:48:56 CEST 2020
;; MSG SIZE  rcvd: 58

As far as I understand, instead of 2.0.0.0, the iodined dns server should respond with MYIPADDRESS. What's wrong and is this a bug?

yarrick commented 4 years ago

Yes, this seems wrong. The same happens when I test it.

yarrick commented 4 years ago

I tested with IPv6 which gave a hint:

dig ovca.ml -t NS @::1

; <<>> DiG 9.11.20-RedHat-9.11.20-1.fc32 <<>> ovca.ml -t NS @::1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36116
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; QUESTION SECTION:
;ovca.ml.           IN  NS

;; ANSWER SECTION:
ovca.ml.        3600    IN  NS  ns.ovca.ml.

;; ADDITIONAL SECTION:
ns.ovca.ml.     3600    IN  A   10.0.0.0

;; Query time: 0 msec
;; SERVER: ::1#53(::1)
;; WHEN: Thu Jul 23 21:10:41 CEST 2020
;; MSG SIZE  rcvd: 58

2 = AF_INET and 10 = AF_INET6 on Linux.

The code encoding the reply in src/dns.c was not updated after q->destination changed its type to struct sockaddr_storage. Submitting fix.

yarrick commented 4 years ago

Thanks for the bug report!