unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Gary Johnson <lambdatronic@disroot.org>
To: Bone Baboon <bone.baboon@disroot.org>
Cc: phil@beadling.co.uk, help-guix@gnu.org
Subject: Re: Edits to `etc/resolv.conf` being overwritten
Date: Fri, 02 Apr 2021 12:07:24 -0400	[thread overview]
Message-ID: <87blaw1xhf.fsf@disroot.org> (raw)
In-Reply-To: <87eefsg7fk.fsf@disroot.org>

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	other threads:[~2021-04-02 16:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02  1:36 Edits to `etc/resolv.conf` being overwritten Bone Baboon
2021-04-02  4:57 ` Jérémy Korwin-Zmijowski
2021-04-02  7:43 ` phil
2021-04-02 13:08   ` Bone Baboon
2021-04-02 16:07     ` Gary Johnson [this message]
2021-04-06 21:41       ` Bone Baboon
2021-04-07 14:34         ` Gary Johnson
2021-04-08 19:07           ` Bone Baboon
2021-04-08 19:17             ` Vincent Legoll
2021-04-10  3:40               ` Bone Baboon
2021-04-10  9:23                 ` Vincent Legoll
2021-04-10 19:50                   ` Bone Baboon
2021-04-09  3:22             ` Vladimir Sedach
2021-04-10  3:28               ` Bone Baboon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87blaw1xhf.fsf@disroot.org \
    --to=lambdatronic@disroot.org \
    --cc=bone.baboon@disroot.org \
    --cc=help-guix@gnu.org \
    --cc=phil@beadling.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).