[systemd-devel] Private network namespace and /etc/resolv.conf

Thomas Köller thomas at koeller.dyndns.org
Sat Sep 14 11:36:57 UTC 2024


I am writing a service that does the following:

1. Uses 'NetworkNamespacePath = /var/run/netns/vpnlink'

2. Uses 'TemporaryFileSystem = %E' to create it's own /etc

3. Runs the 'dhclient' command to configure a network interface

The dhclient command is supposed to create (or modifiy) 
/etc/resolv.conf, but it does not:

Sep 14 13:18:53 yoga dhclient[10128]: DHCPACK of 10.33.56.46 from 
10.33.63.254 (xid=0xa148446c)
Sep 14 13:18:53 yoga dhclient[10159]: DHCP action:
Sep 14 13:18:53 yoga dhclient[10159]:   Reason = BOUND, interface = 
wlan_builtin, media type = *unset*
Sep 14 13:18:53 yoga dhclient[10159]:   new address = 10.33.56.46, old 
address = *unset*, requested address = *unset*
Sep 14 13:18:55 yoga dhclient[10128]: bound to 10.33.56.46 -- renewal in 
1602 seconds.
Sep 14 13:18:55 yoga cat[10191]: cat: /etc/resolv.conf: No such file or 
directory

The lines generating the above output are:

ExecStartPre = dhclient -4 -pf ${PID} -lf ${LEASES} %i
ExecStartPre = cat /etc/resolv.conf

In an attempt at diagnosing the problem, I changed the dhclient command 
to a simple 'echo':

#ExecStartPre = dhclient -4 -pf ${PID} -lf ${LEASES} %i
ExecStartPre = sh -c 'echo \'test\' >%E/resolv.conf'
ExecStartPre = cat %E/resolv.conf

Again, the file is not created, although the echo command executes 
without error.

     Process: 10980 ExecStartPre=sh -c echo 'test' >/etc/resolv.conf 
(code=exited, status=0/SUCCESS)
     Process: 10981 ExecStartPre=cat /etc/resolv.conf (code=exited, 
status=1/FAILURE)

I suspect the file /etc/resolv.conf is somehow treated as special, is 
this correct? The interface I am trying to set up lives in the 'vpnlink' 
network namespace and must do so. What are my options?




More information about the systemd-devel mailing list