user1692342
user1692342

Reputation: 5237

DNS Server in C to return IP Address and port number

From my understanding of a DNS Server, a simple explanation is that for a given hostname the DNS server uses a lookup table to return the IP Address of the hostname.

For one of my projects, I used to connect my client to the server through a wifi network, and specify the IP Address and port at which the server is listening on the client. A new requirement has come which asks to specify a DNS server in the network settings, and the DNS server in turn returns the IP Address and port number of my server.

I went through online to check the request/ response to A DNS server, and I found many places it is mentioned that port number is not sent by the DNS Server. Is it right?

I have coded my project in Visual studio 2005. Is there any libray/code of a DNS Server which I can integrate with my existing visual studio project? And is it possible, that for a particular host name I can specify the port number in the response?

I have checked many source codes for DNS Server in C like ldns/ bind , but I have not found a way to integrate with visual studio.

Upvotes: 1

Views: 1707

Answers (3)

thuovila
thuovila

Reputation: 2020

Might this be what user is trying to define? DNS SRV record

Upvotes: 1

oleg_g
oleg_g

Reputation: 532

You can specify an additional information about given domain in TXT DNS record. So, you could add text tag:value part into your domain TXT record.

Upvotes: 1

unwind
unwind

Reputation: 399813

That just doesn't make sense, the port is not part of the host's domain name. A given host (=a single domain name) can run any number of applications, i.e. have any number of ports open.

Your idea would require that some form of identity of the desired application was sent to the DNS server for the the look-up, or that it could reply with a list of running services and their ports. It just doesn't work like that, at least as far as I know.

There's nothing stopping you from running a web server (normally on port 80) on any other port, such as 8080 as is often done during development. The URL will then be http://example.com:8080, and since the browser only looks up the example.com part in DNS there's no way for the DNS to override the port number.

Upvotes: 0

Related Questions