Skip to content

Instantly share code, notes, and snippets.

@tomty89
Created February 1, 2022 11:38
Show Gist options
  • Save tomty89/9a0c181af1e67a2da6e47952f34e5a67 to your computer and use it in GitHub Desktop.
Save tomty89/9a0c181af1e67a2da6e47952f34e5a67 to your computer and use it in GitHub Desktop.
temp
[Unit]
Description=dnsmasq - A lightweight DHCP and caching DNS server
Documentation=man:dnsmasq(8)
BindsTo=netns-temp.service
After=network.target netns-temp.service
Before=network-online.target nss-lookup.target
Wants=nss-lookup.target
[Service]
NetworkNamespacePath=/run/netns/temp
ExecStartPre=/usr/bin/dnsmasq --test
ExecStart=/usr/bin/dnsmasq -k --user=dnsmasq --pid-file -C /etc/dnsmasq/temp.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
PrivateDevices=true
ProtectSystem=full
[Unit]
Description=netns for temp
Requisite=systemd-networkd.service
After=systemd-networkd.service
[email protected]
[email protected]
Wants=dnsmasq-temp.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/usr/bin/ip netns add temp
ExecStart=/usr/bin/ip link set temp netns temp
ExecStartPost=/usr/bin/ip -n temp link set lo up
ExecStartPost=/usr/bin/ip -n temp link set temp up
ExecStartPost=/usr/bin/ip -n temp addr add 192.168.150.253/24 dev temp
ExecStartPost=/usr/bin/ip -n temp route add default via 192.168.150.1
ExecStop=/usr/bin/ip -n temp link set temp netns 1
ExecStopPost=/usr/bin/ip netns delete temp
[Install]
[email protected]
DNSStubListenerExtra=192.168.150.1
listen-address=127.0.0.53
bind-interfaces
no-resolv
no-hosts
cache-size=0
server=192.168.150.1
@tomty89
Copy link
Author

tomty89 commented Feb 1, 2022

systemd/systemd@a8d0906 might be an alternative to the extra stub listener

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment