Have you tried your condition template code in the Developer Tools / Template (Jinja) editor?
That’s the best method for debugging these things. I think what you want may be the following:
"{{ '192.168.1.1' in states('sensor.e5377ts_32_primary_dns_server') }}"
You cannot put the full YAML code into the Jinja template editor. Just the value_template: quoted value. Try using the line in my post above and see if it returns either True or False values. It may also help if you place TWO lines in the Template editor to see the actual sensor status value being returned as well as the logical result of your template.
"{{ states('sensor.e5377ts_32_primary_dns_server') }}"
"{{ '192.168.1.1' in states('sensor.e5377ts_32_primary_dns_server') }}"
This automation seems to be one of those that needs much finer conditions, better actions , and a better trigger in my opinion.
Ever five seconds is wasteful and unnecessary.
Just use the state. Essentially your condition could be your trigger.
If you toggle a switch every five seconds then the device you are toggeling will probably not have enough time to boot up and report a different value.
Shouldn’t the condition be something like “only if automation was last triggered x minutes go”? To make sure it doesn’t toggle the switch repeatedly all the time?