On Fri, Feb 24, 2023 at 10:19:38AM +0100, daven...@tuxfamily.org wrote: > However, I didn't notice any vnpc_script malfunction. It does what it is > expected to do. I'm like 99% sure the problem is dhclient deleting and > recreating /etc/resolv.conf as it sees fit, multiple times a day, and > deleting whatever vpnc_script has put in that file.
Then use one of the methods listed at <https://wiki.debian.org/resolv.conf> to address that, and see if it fixes the problem. The simplest one to test would be <https://wiki.debian.org/resolv.conf#Configuring_dhclient>. It doesn't involve installing any new packages. If your testing is successful (e.g. a whole day goes by and the resolv.conf file is not unexpectedly altered), then things get a little bit trickier. If I understand correctly, you're working on a laptop, and your desired configuration is: * At boot time, allow the DHCP client to set up resolv.conf. * Once that has been done, disallow all further modifications of resolv.conf by the DHCP client. * Allow modifications of resolv.conf by vpnc_script at any time. The tricky part here is how to write a function that determines whether dhclient should be allowed to modify the file ("is it boot time") or not. Perhaps you could use something awful like "if the system uptime is less than 5 minutes, allow it". Another hack that comes to mind would be writing something that removes the resolv.conf file at shutdown time. Then, the dhclient hook function would allow dhclient to write the file if and only if it doesn't exist. Or... the reverse of this. Keep a second file which serves as a flag indicating that the resolv.conf file has already been configured once. Remove this flag at boot time (make sure that happens *early*, before dhclient is started), and then write your dhclient hook function to allow the modification if and only if the flag file doesn't exist. Then create the flag file after doing the modification. I'm not sure which of those is the least bad. Maybe you can come up with some other ideas.