help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Edits to `etc/resolv.conf` being overwritten


From: Gary Johnson
Subject: Re: Edits to `etc/resolv.conf` being overwritten
Date: Fri, 02 Apr 2021 12:07:24 -0400

Bone Baboon <bone.baboon@disroot.org> writes:

>> Any suggestion on how to stop my edits of `etc/resolv.conf` from being
>> overwritten?
>>
>> `/etc/resolv.conf` is being overwritten removing changes I save to it.
>> My edits to `etc/resolv.conf` specify some name servers.  Some time
>> after my edits are saved the file is completely rewritten to it's
>> original contents before I made my edits.  The original contents include
>> nameserver, domain and search for my internet service provider's DNS. 

When running Guix System, your OS configuration is meant to be fully
derived from evaluating your `operating-system` definition. This
means, in particular, that you should not manually edit any files
outside of your home directories (i.e., /root and /home/*). This
includes, of course, any files under /etc.

Instead, any custom changes that you want to see under /etc need to be
included in your `operating-system` definition. The way to do this
depends on the change you want to make.

For example, if you want to edit /etc/sudoers, you should include this
field in your `operating-system` definition (on the same level as
`packages`, `services`, and so on):

(sudoers-file (plain-file "sudoers" my-sudoers))

Then remember to define `my-sudoers` somewhere above the
`operating-system` form. Here's an example:

(define my-sudoers
  "root ALL=(ALL) ALL
%wheel ALL=(ALL) ALL
")

Similarly, if you want to modify /etc/hosts, you add this to `operating-system`:

(hosts-file (plain-file "hosts"
                         (string-append (local-host-aliases host-name)
                                        my-host-aliases)))

And again define my-host-aliases somewhere above `operating-system`:

(define my-host-aliases
  "
# Some Servers
123.123.123.100 foo
123.123.123.101 bar
123.123.123.102 baz
")

Most other files under /etc are managed by different services. You
should review the "Guix Services" section of the info pages to find
the appropriate service for whatever files you want to modify.

As of today, I'm not aware of a Guix service that modifies
/etc/resolv.conf other than the network-manager-service-type (which is
what I use on my system).

However, if you are not using NetworkManager and want to manually set
the values in /etc/resolv.conf such that they persist across calls to
`guix system reconfigure`, you should add this form to the `services`
list in your `operating-system` definition:

(simple-service 'resolv-service
                etc-service-type
                `(("resolv.conf" ,(plain-file "resolv.conf" my-resolv.conf))))

And finally remember to define `my-resolv.conf` above `operating-system`:

(define my-resolv.conf
  "# Generated by Guix!
nameserver 255.255.255.1
nameserver ffff:ffff:ffff::1
")

Have fun and happy hacking!
  Gary

-- 
GPG Key ID: 7BC158ED
Use `gpg --search-keys lambdatronic' to find me
Protect yourself from surveillance: https://emailselfdefense.fsf.org
=======================================================================
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

Why is HTML email a security nightmare? See https://useplaintext.email/

Please avoid sending me MS-Office attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]