Page 1 of 1
Networking issue when trying to implement DNS
Posted: Thu Apr 07, 2016 7:43 pm
by lpoulain
I have started writing my own TCP/IP stack (and updating the Wiki along the way)
If a few protocols work (DHCP, ARP), DNS or TCP calls always fail. I see the packet being sent out (and Wireshark does not see any irregularity with it), but there is no response. A few more details:
- My OS seems to implement DHCP successfully as it gets an IP address from the router, so the UDP layer seems fine (e.g. the computed UDP checksum is valid)
- It can successfully ping the DNS server on the Internet
- My OS is running on VirtualBox, but a Linux VM (with the exact same networking settings) can successfully make the same DNS or TCP calls to the same host on the Internet (so it doesn't seem to be a firewall issue). I compared the two DNS packets and they are pretty much the same, save the transaction IDs.
Is there anything else I could be missing?
Re: Networking issue when trying to implement DNS
Posted: Fri Apr 08, 2016 2:08 am
by iansjack
Is the TCP handshake with the DNS server completing successfully? Is there any routing involved or is the DNS server on the same subnet as your client? What mode have you set the network adapter in the two VMs?
Re: Networking issue when trying to implement DNS
Posted: Fri Apr 08, 2016 6:59 am
by lpoulain
The TCP handshake doesn't complete. The client sends the SYN packet and nothing gets received.
The DNS server is outside of my network (I'm using Level 3 DNS). Both VMs are using a bridged network.
Re: Networking issue when trying to implement DNS
Posted: Fri Apr 08, 2016 8:39 am
by iansjack
So the DNS aspect is a red herring. Your real problem is that you are not making a TCP connection with a remote computer. The first thing that I would do would be to try to contact a computer on your local network to check whether the problem is a fundamental problem with your TCP stack or just a problem with routed packets.
Re: Networking issue when trying to implement DNS
Posted: Fri Apr 08, 2016 11:16 am
by lpoulain
It's unclear whether these are the same issue or two different issues.
But I'm not sure the DNS issue is a red herring as it's relying on UDP and not TCP.
I tried to access local machines using TCP, and have the same issue (no packet is being returned)
Re: Networking issue when trying to implement DNS
Posted: Fri Apr 08, 2016 3:09 pm
by SpyderTL
If you are using VirtualBox, then you should be able to start troubleshooting by running two VMs, and having them communicate with each other over the same subnet (i.e. set them both to "Internal Network" in the settings dialog.)
Then hard-code the IP addresses on both ends, and, ideally, run wireshark on one of the VMs.
If this doesn't work then try UDP, and then try simple Ethernet packets. If you still don't get a response, then you've got problems with your TCP/IP stack somewhere.
When all else fails, start hard coding values until it works.
Re: Networking issue when trying to implement DNS
Posted: Sat Apr 09, 2016 11:02 pm
by lpoulain
The idea of using Wireshark inside the other VM was a great idea, thanks.
Once I got sure that the message was actually received by the target, I dug deeper. I finally realized that, contrary to what I thought, Wireshark did not verify the checksums. Once I turned verification on, it showed me that the UDP and TCP checksums were wrong (my UDP checksum was right during my DHCP call, but not my DNS call)
Once I fixed the UDP checksum, the DNS call now works fine. Once my DNS implementation is complete I will work on TCP.
Thanks for the suggestion.