LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-29-2020, 02:54 PM   #1
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 581

Rep: Reputation: 38
systemd: How to replicate ip netns exec resolv.conf override


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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Keepalived: kern.log and syslog flooded with IPVS: Creating netns size=2192 id=xxxx entries !!! sundeepgoel Linux - Server 16 02-21-2017 10:20 AM
Keepalived : IPVS flooding kern.log with Creating netns size=2192 id=xx entries sundeepgoel Linux - Server 1 02-21-2017 06:38 AM
why procfs "/proc/sys/net/ipv4/neigh/default" directory is on present on a network namespace, created by "ip netns add NAME" command haldermi Linux - Networking 1 07-28-2016 03:26 PM
inter netns container connection problem hirura Linux - Networking 0 04-17-2015 05:45 PM
openSuSE 11.2 - now has nscd and netns running - never did before Lunar Linux - Networking 0 01-26-2012 02:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration