Trouble making resolv.conf file immutable

Issues Related to Networking (Wired and Wireless)

Moderator: Moderators

Trouble making resolv.conf file immutable

Postby chasha420 » Sun Mar 03, 2013 12:21

Hi guys, I've gone through this before but dunno what's the problem this time around.

My resolv.conf file gives error when I use chattr to make it unchangable. I need to make it unchangeable so that my dns servers doesn't automatically get overwritten everytime I get on a new connection.

Code: Select all
# chattr +i /etc/resolvconf/run/resolv.conf                                                                                                                                                       
chattr: Inappropriate ioctl for device while reading flags on /etc/resolvconf/run/resolv.conf


Some people told me it's cos of my filesystem which doesn't support that..it's ext4 with luks, fully encrypted setup and I know ext4 has support for that cos in the past it worked for me...and this is my new install.

Please let me know if u have a workaroud or solution for this.

Thanks.
User avatar
chasha420
Advanced Hen
 
Posts: 299
Joined: Thu Mar 31, 2011 15:32
Location: /dev/null

Re: Trouble making resolv.conf file immutable

Postby linuxfluesterer » Sun Mar 03, 2013 12:59

Just an idea...
Set your dns servers in /etc/resolv.conf file.
Or you can set dns servers in networkmanagement settings at least in KDE networkmanager.
I assume in Gnome or else have similar apps.

I don't think, that is due to ext4. It is the way, how Sabayon manages dhcp, networksettings, dns settings...

-Linuxfluesterer (I love KDE ...)
linuxfluesterer
Advanced Hen
 
Posts: 240
Joined: Thu Sep 20, 2012 19:47
Location: Germany

Re: Trouble making resolv.conf file immutable

Postby Matte88 » Sun Mar 03, 2013 13:25

I don't know about changing attributes of files, but maybe a workaround could be changing permissions of /etc/resolvconf/run/resolv.conf to 440?
Image
When I became the sun,
I shone life into the man's hearts.
User avatar
Matte88
Technological Hen
 
Posts: 399
Joined: Wed Dec 29, 2010 14:37
Location: @/etc/entropy/repositories.conf.d/entropy_sabayon-limbo

Re: Trouble making resolv.conf file immutable

Postby chasha420 » Sun Mar 03, 2013 14:22

linuxfluesterer wrote:Just an idea...
Set your dns servers in /etc/resolv.conf file.
Or you can set dns servers in networkmanagement settings at least in KDE networkmanager.
I assume in Gnome or else have similar apps.

I don't think, that is due to ext4. It is the way, how Sabayon manages dhcp, networksettings, dns settings...

-Linuxfluesterer (I love KDE ...)

Damn man I dunno why u post replies when u don't even get my question :scratch:

1) I know that I can set dns servers in resolv.con file...that wasn't the reason I posted.
2) I know I can do that for NetworkManager using nm-applet but there's no global dns server setting...therefore I've to set dns server for each different connection, manually.

The benefit of making resolv.conf unchangeable with a fixed DNS is that no matter what happens, you know that ur config cannot be changed and it's the same for all connections (global setting) regardless of the settings in network manager or whatever.

Currently, I can use wicd & set global dns server & cos of that all my connection whether wired or wireless will share the same dns settings regardless of what is written in resolv.conf before that.

But let's say I'm a user who isn't comfortable with wicd (cos it doesn't have support for configuring advanced vpn settings)...in that case I might use NetworkManager (nm-applet) from gnome and like I said before it doesn't remember ur cloned mac-address after reboot and also u have to manually set dns for various connections which is a chore if you're always on the move & keep on using different connection profiles.

TLDR; how can I make resolv.conf unchangeable...not by changing permission but by making it immutable so that even during system startup it doesn't get overwritten.
User avatar
chasha420
Advanced Hen
 
Posts: 299
Joined: Thu Mar 31, 2011 15:32
Location: /dev/null

Re: Trouble making resolv.conf file immutable

Postby sabayonino » Sun Mar 03, 2013 14:38

you can create a resolv.conf.ahead and add all nameserver contents you want. it will be not overwritten

Code: Select all
# nano -w /etc/resolv.conf.ahead


Code: Select all
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx
[...]
nameserver xxx.xxx.xxx.xxx


It should works fine
User avatar
sabayonino
Sagely Hen
 
Posts: 1577
Joined: Sun Sep 21, 2008 1:12
Location: Italy

Re: Trouble making resolv.conf file immutable

Postby chasha420 » Sun Mar 03, 2013 15:00

Dunno, but ur method doesn't seem to be working...still using the same old dns.

Code: Select all
# nm-tool| grep DNS                                                                                                                                                                               
    DNS:             2**.***.***.**
    DNS:             2**.***.***.**
User avatar
chasha420
Advanced Hen
 
Posts: 299
Joined: Thu Mar 31, 2011 15:32
Location: /dev/null

Re: Trouble making resolv.conf file immutable

Postby chasha420 » Fri Mar 08, 2013 20:05

sabayonino wrote:you can create a resolv.conf.ahead and add all nameserver contents you want. it will be not overwritten

Code: Select all
# nano -w /etc/resolv.conf.ahead


Code: Select all
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx
[...]
nameserver xxx.xxx.xxx.xxx


It should works fine


Okay...sorry for the double post but it seems that you're correct to some extent...writing dns servers in /etc/resov.conf.head works...in the sense that the ones specified are always the first ones.

Notice that you've a typo there Lol --> resolv.conf.ahead

But still the problem of newer connections messing with resolv.conf file isn't solved.
User avatar
chasha420
Advanced Hen
 
Posts: 299
Joined: Thu Mar 31, 2011 15:32
Location: /dev/null

Re: Trouble making resolv.conf file immutable

Postby sabayonino » Fri Mar 08, 2013 20:25

ooops. sorry :)

you can try this :
Code: Select all
# nano -w /etc/dhcpcd.conf


and add
Code: Select all
nohook resolv.conf


restart dhcpcd service
Code: Select all
# /etc/init.d/dhcpcd/restart --nodeps


Hope this help you.

[edit]
to protect your /etc/resolv.conf from being modified by anything is setting the write-protection attr

Code: Select all
# chattr +i /etc/resolv.conf
User avatar
sabayonino
Sagely Hen
 
Posts: 1577
Joined: Sun Sep 21, 2008 1:12
Location: Italy


Return to Networking and Wireless

Who is online

Users browsing this forum: No registered users and 1 guest