0

We had DNS problem in the past with one of our web application coded in php Therefore we used IP addresses instead of the server name and we used HOST file and decided to perform a crash test

When our DNS server is working our web application works fine. However when we switch off our DNS server the code stops working at this line

        $bdd = new PDO('mysql:host=139.XXX.XXX.XXX', 'username', 'pwd',array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
    

It seems that we do not receive answer from the server with the mysql database. The page load during about 20 minutes before we get an error.

Does the remote server reply using reverse DNS lookup ?? So that we don't have answer ?

Thanks for your help !!!

Regards,

Fabian

revox
  • 1
  • In any case, if DNS fails, you can expect pretty much everything to fail. So the answer is to make your DNS highly available instead, preferably geo-redundantly. Hardcoding IPs is the worst answer to this issue and will most certainly bite you in the rear in the future. – bviktor Feb 06 '23 at 22:49

2 Answers2

0

Yes, it does reverse lookup in order to find the matching user/host. https://dev.mysql.com/doc/refman/8.0/en/host-cache.html

The culprit is in the phrase "For each applicable new client connection, the server uses the client IP address to check whether the client host name is in the host cache. If so, the server refuses or continues to process the connection request depending on whether or not the host is blocked. If the host is not in the cache, the server attempts to resolve the host name."

Check https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_skip_name_resolve

0

Sounds like you have to edit the bind-adress in my.cnf?

Check if this helps: How to bind MySQL server to more than one IP address?

Cenzo
  • 11
  • 3