Slow Ansible Response Using External IP

As I was playing with Ansible's ad-hoc commands, I've noticed that one host was struggling. Any command I tried took 15 seconds more for it than for any other host.

# ansible all -a date

Adding IP to /etc/hosts actually solved that trouble which strongly indicated toward issue actually being connected to DNS setup. But, why the hell was my temporary lab even using DNS? It was just a bunch of virtual machines and I definitely didn't want to add all hosts by name. I needed another solution...

After a bit of investigation, I discovered the actual culprit - SSH daemon was trying to resolve IP address. For which purpose you ask? Just to write host name to its log.

The final solution was easy - just adding UseDNS no to /etc/ssh/sshd_config:

# echo -e "\nUseDNS no" | sudo tee -a /etc/ssh/sshd_config'
# sudo systemctl restart sshd

Leave a Reply

Your email address will not be published. Required fields are marked *