Lock your /etc/resolv.conf in OpenWRT

OpenWRT hate me and I hate it too !

Yes it's a weird intro but it's true. Each time i need to edit any setting on their web interface i start cleaning the flat or find something else to do. I'm used to managing classic Linux systems via SSH but I can't find anything in their system.

Even defining you DNS resolver is hard on their system.

Ma Internet connection is provided thanks to DHCP which means i get the IP settings AND a DNS resolver.

Except, I don't need this service from my ISP as I already have my own resolver. And this funny OpenWRT doesn't try to ease my pain.

So I SSH into the router and try the famous **chattr +i /etc/resolv.conf**.
chattr: Operation not supported while reading flags on /etc/resolv.conf

O___o Dafuck !

Hoo it's a symbolic link to /tmp/etc/resolv.conf . Well … why not ?

So I try to chattr +i this file.

It fails too with the same error.



rm /tmp/etc/resolv.conf

rm /etc/resolv.conf

Breathe again

crontab -e

* * * * * printf "#SET VIA CRONTAB\nnameserver\nnameserver\n" > /etc/resolv.conf

We wait one minute.

If the file is right :

chattr +i /etc/resolv.conf

Here it is !

No more trouble.

As usual I fight against stranges choices from this linux distro but at least it's a Linux so you can fiddle with this !

This technique is « ceinture + bretelles » ( belt + braces ) but now I'm sure not to use my ISP's resolvers.