Networking issue when trying to implement DNS

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
lpoulain
Member
Member
Posts: 38
Joined: Mon Dec 21, 2015 7:09 pm

Networking issue when trying to implement DNS

Post 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?
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Networking issue when trying to implement DNS

Post 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?
lpoulain
Member
Member
Posts: 38
Joined: Mon Dec 21, 2015 7:09 pm

Re: Networking issue when trying to implement DNS

Post 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.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Networking issue when trying to implement DNS

Post 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.
lpoulain
Member
Member
Posts: 38
Joined: Mon Dec 21, 2015 7:09 pm

Re: Networking issue when trying to implement DNS

Post 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)
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Networking issue when trying to implement DNS

Post 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. :)
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
lpoulain
Member
Member
Posts: 38
Joined: Mon Dec 21, 2015 7:09 pm

Re: Networking issue when trying to implement DNS

Post 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.
Post Reply