OSDev.org
https://forum.osdev.org/

[solved] no DNS response from real router
https://forum.osdev.org/viewtopic.php?f=1&t=56709
Page 1 of 1

Author:  Klakap [ Sat Jan 28, 2023 6:30 am ]
Post subject:  [solved] no DNS response from real router

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

Author:  nullplan [ Sat Jan 28, 2023 7:04 am ]
Post subject:  Re: no DNS response from real router

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.

Author:  Klakap [ Sat Jan 28, 2023 7:20 am ]
Post subject:  Re: no DNS response from real router

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
Snímka obrazovky_2023-01-28_14-16-51.jpg [ 87.14 KiB | Viewed 1193 times ]

Author:  sounds [ Sat Jan 28, 2023 12:43 pm ]
Post subject:  Re: no DNS response from real router

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.

Author:  Klakap [ Mon Jan 30, 2023 8:52 am ]
Post subject:  Re: no DNS response from real router

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.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/