unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: divoplade <d@divoplade.fr>
To: Katherine Cox-Buday <cox.katherine.e@gmail.com>, help-guix@gnu.org
Subject: Re: How can I have a static IP on one NIC and DHCP on the other?
Date: Tue, 05 Jan 2021 23:08:01 +0100	[thread overview]
Message-ID: <8828ff9c6f2127f6210443046b9011f7276ae0a1.camel@divoplade.fr> (raw)
In-Reply-To: <874kjvuk8t.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 617 bytes --]

Hello Katherine,

Le mardi 05 janvier 2021 à 15:49 -0600, Katherine Cox-Buday a écrit :
> Is it possible to define an operating-system which runs DHCP on one
> NIC,
> and has a static address on the other?

For a slightly different problem (adding a static ipv6 on the same
interface, [1]), I ended up creating a service that just did "ip
address add dev <device> <address>" on startup, and it seems to work.
Maybe you can do something similar? The "ip" program is from the
iproute package, defined in (gnu packages linux).

[1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44571

Hoping that it helps.

divoplade

[-- Attachment #2: static-ipv6.scm --]
[-- Type: text/x-scheme, Size: 1731 bytes --]

(define-module (gnu services static-ipv6)
  #:use-module (gnu services)
  #:use-module (gnu services shepherd)
  #:use-module (guix gexp)
  #:use-module (guix modules)
  #:use-module (guix records)
  #:use-module (gnu packages linux)
  #:use-module (ice-9 match)
  #:use-module (ice-9 optargs))

(define-record-type* <static-ipv6-configuration>
  static-ipv6-configuration
  make-static-ipv6-configuration
  static-ipv6-configuration?
  (iproute static-ipv6-configuration-iproute (default iproute))
  (address static-ipv6-configuration-address)
  (interface static-ipv6-configuration-interface))

(export <static-ipv6-configuration>
	static-ipv6-configuration
	make-static-ipv6-configuration
	static-ipv6-configuration?
	static-ipv6-configuration-iproute
	static-ipv6-configuration-address
	static-ipv6-configuration-interface)

(define static-ipv6-shepherd-service
  (match-lambda
    (($ <static-ipv6-configuration>
	iproute address interface)
     (list
      (shepherd-service
       (provision '(static-ipv6))
       (documentation (format #f "Add ~a/128 to interface ~a"
			      address interface))
       (requirement '(user-processes loopback syslogd))
       (start
	#~(lambda _
	    (system*
	     (string-append #$iproute "/sbin/ip")
	     "address"
	     "add"
	     "dev"
	     #$interface
	     (string-append #$address "/128"))))
       (stop
	#~(lambda _
	    (system*
	     (string-append #$iproute "/sbin/ip")
	     "address"
	     "delete"
	     "dev"
	     #$interface
	     (string-append #$address "/128")))))))))

(define-public static-ipv6-service-type
  (service-type (name 'static-ipv6)
		(extensions
		 (list
		  (service-extension
		   shepherd-root-service-type
		   static-ipv6-shepherd-service)))))

      reply	other threads:[~2021-01-05 22:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05 21:49 How can I have a static IP on one NIC and DHCP on the other? Katherine Cox-Buday
2021-01-05 22:08 ` divoplade [this message]

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=8828ff9c6f2127f6210443046b9011f7276ae0a1.camel@divoplade.fr \
    --to=d@divoplade.fr \
    --cc=cox.katherine.e@gmail.com \
    --cc=help-guix@gnu.org \
    /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).