.NET: Why is this domain not allowed?

I am trying to programmatically check if a given domain name exists.

The following line of code works as expected:

IPHostEntry IPhst =Dns.GetHostEntry("google.com"); 

But it does not work for multiple domains on the same host at the same time. For example, the following excludes.

 IPHostEntry IPhst =Dns.GetHostEntry("bks-campus.ch"); 

The resulting exception is identical to the exceptions that are thrown when the domain name does not exist at all.

It is strange that the domain really exists. I can view it from the same machine that just ran the code above.

What could be the problem here and how can I get around this?

Edit: Dig also agrees that this domain name really exists:

 dig bks-campus.ch ; <<>> DiG 9.5.0-P2 <<>> bks-campus.ch ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14744 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0 ;; QUESTION SECTION: ;bks-campus.ch. IN A ;; AUTHORITY SECTION: bks-campus.ch. 3600 IN SOA dns1.bks-campus.ch. hostmaster.kanti-chur.ch. 1275546863 10800 3600 604800 86400 ;; Query time: 1214 msec ;; SERVER: 192.168.0.1#53(192.168.0.1) ;; WHEN: Fri Jul 2 12:50:10 2010 ;; MSG SIZE rcvd: 94 
+4
source share
7 answers
 ; <<>> DiG 9.3.2 <<>> any bks-campus.ch @olympus ; (1 server found) ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1406 ;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 1, ADDITIONAL: 1 ;; QUESTION SECTION: ;bks-campus.ch. IN ANY ;; ANSWER SECTION: bks-campus.ch. 86400 IN SOA dns1.bks-campus.ch. hostmaster.kanti-chur.ch. 1275546863 10800 3600 604800 86400 bks-campus.ch. 86400 IN MX 20 cws02.netgrouper.ch. bks-campus.ch. 86400 IN MX 20 cws01.netgrouper.ch. bks-campus.ch. 86400 IN NS dns1.bks-campus.ch. ;; AUTHORITY SECTION: bks-campus.ch. 86400 IN NS dns1.bks-campus.ch. ;; ADDITIONAL SECTION: cws02.netgrouper.ch. 32548 IN A 194.150.160.32 ;; Query time: 179 msec ;; SERVER: 192.168.2.4#53(192.168.2.4) ;; WHEN: Fri Jul 02 13:00:48 2010 ;; MSG SIZE rcvd: 193 

There are no A (IPv4) bks-campus.ch for bks-campus.ch , nor CNAME (alias), nor AAAA (IPv6). The answer only shows which servers handle mail (MX), dns (NS), and some administrative record (SOA). There is nothing in the answer that tells bks-campus.ch where to find bks-campus.ch . Add an A (or CNAME) entry and it will work.

+5
source

google.com has an A record associating it with an IP address. bks-campus.ch does not have A, AAAA or CNAME entries, so you get an error.

Perhaps your browser will automatically add www if it cannot find the A record for the domain.


Edit: your dig output confirms that bks-campus.ch exists but does not have an A.

+4
source

bks-campus.ch does not have a DNS record. The browser probably translates to www.bks-campus.ch , which has a DNS record, and is likely to work with code as well.

EDIT: A domain name exists, but your DNS probably doesn't know this. Mine does not know, but knows www.bks-campus.ch .

+2
source

What you are trying to do with your code is to check if the domain has a dns A regressive entry for bks-campus.ch. What you want to do is request a SOA record for the domain. see this CodeProject project that is looking for an MX record. Just change the record type to SOA

This will only work if the domain has been delegated to the name server. There are some domains that were registered and simply did not point to a DNS server. In these cases, you simply get an error message if you enter the domain name into the browser.

The best way to find out if a domain is registered is to search for WHOIS. They are managed by TLD registries so people can check who registered a domain name. If you connect to port 43 whois.nic.coop and enter the domain name "nosuchdomain.coop", you will receive information about who registered this domain.

 .coop registry WHOIS server For help on using this server use "?" (without the quotes). For more .coop information browse to http://www.coop nosuchdomain.coop No domain records were found to match "nosuchdomain.coop" -------------------------------------------------------------------------------- The .coop registry WHOIS database provides information for .coop registered names only. Although every effort is made to maintain the accuracy of the WHOIS data, accuracy cannot be guaranteed. This service is intended only for query-based access. You agree that you will use this data only for lawful purposes and that, under no circumstances will you use this data to: (a) allow, enable, or otherwise support the transmission by e-mail, telephone, or facsimile of mass unsolicited, commercial advertising or solicitations to entities other than the data recipient own existing customers; or (b) enable high volume, automated, electronic processes that send queries or data to the systems of Registry Operator or any ICANN-Accredited Registrar, except as reasonably necessary to register domain names or modify existing registrations. The compilation, repackaging, dissemination or other use of this Data is expressly prohibited without the prior written consent of dotCoop. All rights reserved. dotCoop reserves the right to modify these terms at any time. By submitting this query, you agree to abide by this policy. BY USING THE WHOIS SERVICE AND THE DATA CONTAINED HEREIN OR IN ANY REPORT GENERATED WITH RESPECT THERETO, IT IS ACCEPTED THAT DOTCOOP IS NOT LIABLE FOR ANY DAMAGES OF ANY KIND ARISING OUT OF, OR IN CONNECTION WITH, THE REPORT OR THE INFORMATION PROVIDED BY THE WHOIS SERVICE, NOR OMISSIONS OR MISSING INFORMATION. THE RESULTS OF ANY WHOIS REPORT OR INFORMATION PROVIDED BY THE WHOIS SERVICE CANNOT BE RELIED UPON IN CONTEMPLATION OF LEGAL PROCEEDINGS WITHOUT FURTHER VERIFICATION, NOR DO SUCH RESULTS CONSTITUTE A LEGAL OPINION. 

If you open the socket on this port on the correct server and simply send them a domain, record the response and then parse it to find out if the WHOIS server reports whether the domain is registered or not.

+2
source

Another way to find out if a given domain exists is to search for NS for that domain. If the domain exists, it must have an NS record, even if the registered name servers for the domain timeout.

+1
source

Try setting up DNS servers on NETWORK ADAPTER on 4.2.2.2 or 4.2.2.3 . Basically, if I'm not mistaken, this will work, because sometimes the DNS servers of Internet service providers do not respond in a timely manner. Let me know your results in the comments.

0
source

There are many reasons for spring, but most likely your DNS infrastructure is not configured to resolve this domain.

Keep in mind that even if you can access it from a web browser, it does not tell you much if you are also viewing a web proxy. It just tells you that the proxy can allow the host, not the local machine.

The easiest way is to try nslookup from the command line

 nslookup bks-campus.ch 

If this fails, the DNS used by your machine cannot solve this problem, so your code cannot.

If this goes away, then more research will be needed. Post back more info :)

0
source

Source: https://habr.com/ru/post/1314534/


All Articles