unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* How can I have a static IP on one NIC and DHCP on the other?
@ 2021-01-05 21:49 Katherine Cox-Buday
  2021-01-05 22:08 ` divoplade
  0 siblings, 1 reply; 2+ messages in thread
From: Katherine Cox-Buday @ 2021-01-05 21:49 UTC (permalink / raw)
  To: help-guix

Is it possible to define an operating-system which runs DHCP on one NIC,
and has a static address on the other?

I'm getting:

guix system: error: service 'networking' provided more than once

if i try and define service for dhcp-client-service-type and
static-networking-service.

-- 
Katherine


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How can I have a static IP on one NIC and DHCP on the other?
  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
  0 siblings, 0 replies; 2+ messages in thread
From: divoplade @ 2021-01-05 22:08 UTC (permalink / raw)
  To: Katherine Cox-Buday, help-guix

[-- 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)))))

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-05 22:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).