When using ip netns exec to run a command in a namespace, it's possible to override /etc/resolv.conf by creating /etc/netns/<ns name>/resolv.conf.
I'm trying to achieve the same result using a systemd unit, but not having much success. I have created the network namespace correctly and am now trying to start the following:
Code:
[Unit]
Description=HDHomerun DVR running in Netns
# Require the network namespace is set up
Requires=netns@HDnet.service
After=netns@HDnet.service
JoinsNamespaceOf=netns@HDnet.service
# Require the interface is set up
Requires=attach-veth@HDnet.service
After=attach-veth@HDnet.service
[Service]
Type=simple
RemainAfterExit=yes
PrivateNetwork=true
# Need our own copy
PrivateMounts=on
BindPaths=/etc/netns/HDnet/resolv.conf:/etc/resolv.conf
# Add additional limitation on privileges
User=eddie
# Start the HDHomerun DVR service
ExecStart=/usr/local/bin/hdhomerun_record start
# Stop the HDHomerun DVR service
ExecStop=/usr/local/bin/hdhomerun_record stop
[Install]
WantedBy=multi-user.target
However, using tcpdump, I can see that this process is still using the global /etc/resolv.conf, not the override provided by the BindPaths directive.
I tested the equivalent of BindPaths with "mount --bind /etc/netns/HDnet/resolv.conf /etc/resolv.conf" in the root namespace and it works exactly as I would expect.
Has anyone any ideas why the BindPaths doesn't work.
Cheers.