I would want to append the below line to resolv.conf of all servers in our aws env and make sure it doesn't get overwritten
options timeout:1 attempts:1 rotate
I came across dhclient enter and exit hooks, which seemed to be the way to achieve this.
I tried placing enter hook with name /etc/dhcp/dhclient-enter-hooks with content as below
#!/bin/bash sed -i '$ a\options timeout:1 attempts:1 rotate' /etc/resolv.conf
And when i run dhclient, it adds the same line several times to the beginning of the file. And sometimes, few times in the beginning and few times in the end. Exit hook does the same thing.
Why does the line gets added several times to resolv.conf, instead of only once? And this behaviour is random. Sometimes it adds the same line 4 times while running dhclient. Sometimes 3 and so on. What's the correct way of doing this?