[solved] no DNS response from real router

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

[solved] no DNS response from real router

Post by Klakap »

I am currently testing my code on real machine. My router properly responds to DHCP and ARP protocol, however, when I send DNS query, there is no response. So far I checked:
- my driver: there surely is not problem, it is working perfectly
- ARP: router properly responds to ARP request for DNS server IP
- DNS query: I doubt that error is here, because my code works under QEMU and Virtualbox and there is no error shown in Wireshark.
What is quite strange, when I start Virtualbox with network option bridge, router responds to DNS query properly. However when I start my OS on real computer, there is no DNS reply. So I am wondering that maybe there is some overlooked aspect in initalizing communication with real router. Here is how my code works now on real computer:
- > I send DHCP Discover asking for IP 192.168.1.100, router IP and Domain Name Server IP
< - Router send DHCP Offer with IP 192.168.1.100, router IP 192.168.1.1 and Domain Name Server IP 192.168.1.1
- > I send DHCP Request for 192.168.1.100
< - Router send ARP Request for IP 192.168.1.100
- > I send ARP Reply to router
< - Router send DHCP Acknowledge
- > I send DNS query
< - In QEMU, Virtualbox and even Virtualbox bridge Router responds with DNS Reply, however on real hardware it do not
Am I missing something? Any help would be appreciated.

P.S. I am currently rewriting BleskOS to C, so code on GitHub is not my actual code
Last edited by Klakap on Mon Jan 30, 2023 8:53 am, edited 1 time in total.
nullplan
Member
Member
Posts: 1789
Joined: Wed Aug 30, 2017 8:24 am

Re: no DNS response from real router

Post by nullplan »

I would guess that there is something wrong with your DNS query that QEMU and VBox are not checking but the router is. Dump the traffic into Wireshark, it is stricter about checking things.
Carpe diem!
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: no DNS response from real router

Post by Klakap »

Wireshark do not see anything wrong with my DNS query. Screenshot here is from Virtualbox bridge communication, therefore my IP is 192.168.1.101.
Attachments
Snímka obrazovky_2023-01-28_14-16-51.jpg
sounds
Member
Member
Posts: 112
Joined: Sat Feb 04, 2012 5:03 pm

Re: no DNS response from real router

Post by sounds »

I can't imagine why, but on the real computer the DNS request might be different. Can you capture the packets sent? Easy options are: (1) run a packet capture on your router if you have a router that can do that (2) use an ethernet hub and a separate box to capture with, as long as the ethernet hub is either a dumb hub that forwards all packets to all ports, or is a switch that has a management UI that lets you set it up to forward all packets from a port to a capture port.
Klakap
Member
Member
Posts: 297
Joined: Sat Mar 10, 2018 10:16 am

Re: no DNS response from real router

Post by Klakap »

sounds wrote:I can't imagine why, but on the real computer the DNS request might be different. Can you capture the packets sent?
Thank you for suggestion. I've solved this problem. It was really sneaky mistake. I used malloc() instead of calloc(). In emulators it do not matter, because they have zeroes in whole free memory, but it is not case on real computer. I was not rewriting all fields, so I was sending malformed packet. When I zeroed packet with calloc(), everything works perfectly.
Post Reply