Few weeks ago in one of the servers we faces strange issue: The website couldn’t send emails using remote SMTP.
First i thought it was related to SMTP port, credentials etc. – but everything was OK there. So then i tries to ping google.com and got surprised. It wasn’t worked. Simple ping didn’t work.
So it was obviously corrupted DNS issue.
First i tried the easier way, which is recommended by developers.google.com, adding Google DNS IP addresses to resolv.conf file
sudo vi /etc/resolv.conf
But it didn’t help.
So i decided to go into deeper and solving it using netplan.
Solving DNS issue in Ubuntu/Debian servers:
Step 1: Open netplan file.
sudo nano /etc/netplan
Step 2: Add the following code under ens* block (following YAML syntax is required)
addresses: [188.8.131.52, 184.108.40.206]
It should look like this:
Step 3: Apply the rules:
sudo netplan apply
Step 4: Check if it works:
systemd-resolve --status | grep 'DNS Servers' -A2
It should show something like this
If you see 220.127.116.11 and 18.104.22.168 there, then the problem should be resolved now.