Serving DHCP Under Ubuntu 18.04 [duplicate]












0
















This question is an exact duplicate of:




  • Convert /etc/network/interfaces to netplan for floating IP

    2 answers




Problem Summary



I have two network interfaces in the machine, and need them to behave in the following way:




  • enp3s0: Main network interface for the machine. Receive over DHCP an IP address (will be in 172.16.0.0/24), a gateway, and a DNS resolver for the office network and the world at large. Default route is to this received gateway.


  • enp2s0: Local subnet consisting of nothing more than 2 meters away, and nothing that should have access to the main network. Serve DHCP on this network (192.168.0.0/24, domain is .localnet), and provide the local machine with DNS resolution of .localnet clients.



I had a working solution for all this under 16.04 using /etc/network/ and dnsmasq (no NetworkManager), but I'm just lost in the new era of netplan and systemd-resolved. Everything just keeps fighting everything else.



So, what's my right, modern solution to make this work right? Ideally in such a way that I won't have to change it for 20.04.



Additional information



For reference, here is the script that did what I needed under 16.04.



#!/bin/bash
#
# Configure the PC to use dual network adapters.
#
# usage: dualnetwork.sh <hinetif> <localnetif>
#
# This configuration is based around the use of the classic ifupdown
# configuration files rather than NetworkManager. This is substantially
# more stable and easier to work with. It is probably prudent to also
# uninstall NetworkManager once this is done:
# sudo apt-get remove network-manager
#
# Must run as root.
#
# Rob Gaddi, 29 Jan 2019

GENERATED="Generated by $0 at $(date)"
HINET=$1
LOCALNET=$2

abort () {
echo $*
exit 1
}

[[ ! -z "$LOCALNET" ]] || abort Must provide hinet and localnet interfaces.
ip -br addr | grep $HINET || abort Interface $HINET not found
ip -br addr | grep $LOCALNET || abort Interface $LOCALNET not found

####################################################################
echo Configuring network interfaces
####################################################################
mkdir -p /etc/network/interfaces.d
echo source-directory /etc/network/interfaces.d > /etc/network/interfaces
cat <<-CONF > /etc/network/interfaces.d/hinet
# $GENERATED
auto $HINET
iface $HINET inet dhcp
CONF
cat <<-CONF > /etc/network/interfaces.d/localnet
# $GENERATED
allow-hotplug $LOCALNET
iface $LOCALNET inet static
address 192.168.0.20/24

iface $LOCALNET inet static
address 192.168.254.20/24
CONF

####################################################################
echo Installing and configuring dnsmasq
####################################################################
apt-get install --reinstall -y dnsmasq
mkdir -p /etc/dnsmasq.d
cat <<-CONF > /etc/dnsmasq.d/dualnetwork.conf
# $GENERATED
no-negcache
dhcp-range=192.168.0.100,192.168.0.150,4h
interface=$LOCALNET
domain=localnet
dhcp-fqdn
log-dhcp
CONF
systemctl enable --now dnsmasq.service


Edit



This differs from Convert /etc/network/interfaces to netplan for floating IP in that the problem is not netplanning the machine IP addresses; that part is pretty easy. The problem is making the system serve DHCP on one network. When I tried it the obvious way, dnsmasq and systemd-resolved kept stepping on one another's toes. When I tried just disabling systemd-resolvd and letting dnsmasq do all the work it never got the upstream DNS server when it accepted the main network DHCP.










share|improve this question















marked as duplicate by Thomas, Charles Green, Eric Carvalho, user2405, Fabby Feb 10 at 21:53


This question was marked as an exact duplicate of an existing question.



















  • how and why are dnsmasq and systemd-resolved "stepping on one another's toes"? systemd-resolved should only bind to 127.0.0.53 and should be allowed to manage /etc/resolv.conf, which dnsmasq should not need to touch. Where is the toe-stepping happening from dnsmasq?

    – slangasek
    Feb 5 at 0:11











  • @slangasek The problem is that I need dnsmasq to be acting as a DNS resolver to be able to access .localnet resources by name. On my working systems (16.04) dnsmasq takes over ``/etc/resolv.conf``` and points it to 127.0.0.1. Then dnsmasq listens on port 53 to serve DNS. On my non-working 18.04 system, systemd-resolvd points /etc/resolv.conf at 127.0.0.53 as you said. And systemd-resolve --status shows the company DNS server on enp3s0's chain. But when I try to dig local addresses I get "Temporary failure in name resolution"

    – Rgaddi
    Feb 5 at 21:38
















0
















This question is an exact duplicate of:




  • Convert /etc/network/interfaces to netplan for floating IP

    2 answers




Problem Summary



I have two network interfaces in the machine, and need them to behave in the following way:




  • enp3s0: Main network interface for the machine. Receive over DHCP an IP address (will be in 172.16.0.0/24), a gateway, and a DNS resolver for the office network and the world at large. Default route is to this received gateway.


  • enp2s0: Local subnet consisting of nothing more than 2 meters away, and nothing that should have access to the main network. Serve DHCP on this network (192.168.0.0/24, domain is .localnet), and provide the local machine with DNS resolution of .localnet clients.



I had a working solution for all this under 16.04 using /etc/network/ and dnsmasq (no NetworkManager), but I'm just lost in the new era of netplan and systemd-resolved. Everything just keeps fighting everything else.



So, what's my right, modern solution to make this work right? Ideally in such a way that I won't have to change it for 20.04.



Additional information



For reference, here is the script that did what I needed under 16.04.



#!/bin/bash
#
# Configure the PC to use dual network adapters.
#
# usage: dualnetwork.sh <hinetif> <localnetif>
#
# This configuration is based around the use of the classic ifupdown
# configuration files rather than NetworkManager. This is substantially
# more stable and easier to work with. It is probably prudent to also
# uninstall NetworkManager once this is done:
# sudo apt-get remove network-manager
#
# Must run as root.
#
# Rob Gaddi, 29 Jan 2019

GENERATED="Generated by $0 at $(date)"
HINET=$1
LOCALNET=$2

abort () {
echo $*
exit 1
}

[[ ! -z "$LOCALNET" ]] || abort Must provide hinet and localnet interfaces.
ip -br addr | grep $HINET || abort Interface $HINET not found
ip -br addr | grep $LOCALNET || abort Interface $LOCALNET not found

####################################################################
echo Configuring network interfaces
####################################################################
mkdir -p /etc/network/interfaces.d
echo source-directory /etc/network/interfaces.d > /etc/network/interfaces
cat <<-CONF > /etc/network/interfaces.d/hinet
# $GENERATED
auto $HINET
iface $HINET inet dhcp
CONF
cat <<-CONF > /etc/network/interfaces.d/localnet
# $GENERATED
allow-hotplug $LOCALNET
iface $LOCALNET inet static
address 192.168.0.20/24

iface $LOCALNET inet static
address 192.168.254.20/24
CONF

####################################################################
echo Installing and configuring dnsmasq
####################################################################
apt-get install --reinstall -y dnsmasq
mkdir -p /etc/dnsmasq.d
cat <<-CONF > /etc/dnsmasq.d/dualnetwork.conf
# $GENERATED
no-negcache
dhcp-range=192.168.0.100,192.168.0.150,4h
interface=$LOCALNET
domain=localnet
dhcp-fqdn
log-dhcp
CONF
systemctl enable --now dnsmasq.service


Edit



This differs from Convert /etc/network/interfaces to netplan for floating IP in that the problem is not netplanning the machine IP addresses; that part is pretty easy. The problem is making the system serve DHCP on one network. When I tried it the obvious way, dnsmasq and systemd-resolved kept stepping on one another's toes. When I tried just disabling systemd-resolvd and letting dnsmasq do all the work it never got the upstream DNS server when it accepted the main network DHCP.










share|improve this question















marked as duplicate by Thomas, Charles Green, Eric Carvalho, user2405, Fabby Feb 10 at 21:53


This question was marked as an exact duplicate of an existing question.



















  • how and why are dnsmasq and systemd-resolved "stepping on one another's toes"? systemd-resolved should only bind to 127.0.0.53 and should be allowed to manage /etc/resolv.conf, which dnsmasq should not need to touch. Where is the toe-stepping happening from dnsmasq?

    – slangasek
    Feb 5 at 0:11











  • @slangasek The problem is that I need dnsmasq to be acting as a DNS resolver to be able to access .localnet resources by name. On my working systems (16.04) dnsmasq takes over ``/etc/resolv.conf``` and points it to 127.0.0.1. Then dnsmasq listens on port 53 to serve DNS. On my non-working 18.04 system, systemd-resolvd points /etc/resolv.conf at 127.0.0.53 as you said. And systemd-resolve --status shows the company DNS server on enp3s0's chain. But when I try to dig local addresses I get "Temporary failure in name resolution"

    – Rgaddi
    Feb 5 at 21:38














0












0








0


1







This question is an exact duplicate of:




  • Convert /etc/network/interfaces to netplan for floating IP

    2 answers




Problem Summary



I have two network interfaces in the machine, and need them to behave in the following way:




  • enp3s0: Main network interface for the machine. Receive over DHCP an IP address (will be in 172.16.0.0/24), a gateway, and a DNS resolver for the office network and the world at large. Default route is to this received gateway.


  • enp2s0: Local subnet consisting of nothing more than 2 meters away, and nothing that should have access to the main network. Serve DHCP on this network (192.168.0.0/24, domain is .localnet), and provide the local machine with DNS resolution of .localnet clients.



I had a working solution for all this under 16.04 using /etc/network/ and dnsmasq (no NetworkManager), but I'm just lost in the new era of netplan and systemd-resolved. Everything just keeps fighting everything else.



So, what's my right, modern solution to make this work right? Ideally in such a way that I won't have to change it for 20.04.



Additional information



For reference, here is the script that did what I needed under 16.04.



#!/bin/bash
#
# Configure the PC to use dual network adapters.
#
# usage: dualnetwork.sh <hinetif> <localnetif>
#
# This configuration is based around the use of the classic ifupdown
# configuration files rather than NetworkManager. This is substantially
# more stable and easier to work with. It is probably prudent to also
# uninstall NetworkManager once this is done:
# sudo apt-get remove network-manager
#
# Must run as root.
#
# Rob Gaddi, 29 Jan 2019

GENERATED="Generated by $0 at $(date)"
HINET=$1
LOCALNET=$2

abort () {
echo $*
exit 1
}

[[ ! -z "$LOCALNET" ]] || abort Must provide hinet and localnet interfaces.
ip -br addr | grep $HINET || abort Interface $HINET not found
ip -br addr | grep $LOCALNET || abort Interface $LOCALNET not found

####################################################################
echo Configuring network interfaces
####################################################################
mkdir -p /etc/network/interfaces.d
echo source-directory /etc/network/interfaces.d > /etc/network/interfaces
cat <<-CONF > /etc/network/interfaces.d/hinet
# $GENERATED
auto $HINET
iface $HINET inet dhcp
CONF
cat <<-CONF > /etc/network/interfaces.d/localnet
# $GENERATED
allow-hotplug $LOCALNET
iface $LOCALNET inet static
address 192.168.0.20/24

iface $LOCALNET inet static
address 192.168.254.20/24
CONF

####################################################################
echo Installing and configuring dnsmasq
####################################################################
apt-get install --reinstall -y dnsmasq
mkdir -p /etc/dnsmasq.d
cat <<-CONF > /etc/dnsmasq.d/dualnetwork.conf
# $GENERATED
no-negcache
dhcp-range=192.168.0.100,192.168.0.150,4h
interface=$LOCALNET
domain=localnet
dhcp-fqdn
log-dhcp
CONF
systemctl enable --now dnsmasq.service


Edit



This differs from Convert /etc/network/interfaces to netplan for floating IP in that the problem is not netplanning the machine IP addresses; that part is pretty easy. The problem is making the system serve DHCP on one network. When I tried it the obvious way, dnsmasq and systemd-resolved kept stepping on one another's toes. When I tried just disabling systemd-resolvd and letting dnsmasq do all the work it never got the upstream DNS server when it accepted the main network DHCP.










share|improve this question

















This question is an exact duplicate of:




  • Convert /etc/network/interfaces to netplan for floating IP

    2 answers




Problem Summary



I have two network interfaces in the machine, and need them to behave in the following way:




  • enp3s0: Main network interface for the machine. Receive over DHCP an IP address (will be in 172.16.0.0/24), a gateway, and a DNS resolver for the office network and the world at large. Default route is to this received gateway.


  • enp2s0: Local subnet consisting of nothing more than 2 meters away, and nothing that should have access to the main network. Serve DHCP on this network (192.168.0.0/24, domain is .localnet), and provide the local machine with DNS resolution of .localnet clients.



I had a working solution for all this under 16.04 using /etc/network/ and dnsmasq (no NetworkManager), but I'm just lost in the new era of netplan and systemd-resolved. Everything just keeps fighting everything else.



So, what's my right, modern solution to make this work right? Ideally in such a way that I won't have to change it for 20.04.



Additional information



For reference, here is the script that did what I needed under 16.04.



#!/bin/bash
#
# Configure the PC to use dual network adapters.
#
# usage: dualnetwork.sh <hinetif> <localnetif>
#
# This configuration is based around the use of the classic ifupdown
# configuration files rather than NetworkManager. This is substantially
# more stable and easier to work with. It is probably prudent to also
# uninstall NetworkManager once this is done:
# sudo apt-get remove network-manager
#
# Must run as root.
#
# Rob Gaddi, 29 Jan 2019

GENERATED="Generated by $0 at $(date)"
HINET=$1
LOCALNET=$2

abort () {
echo $*
exit 1
}

[[ ! -z "$LOCALNET" ]] || abort Must provide hinet and localnet interfaces.
ip -br addr | grep $HINET || abort Interface $HINET not found
ip -br addr | grep $LOCALNET || abort Interface $LOCALNET not found

####################################################################
echo Configuring network interfaces
####################################################################
mkdir -p /etc/network/interfaces.d
echo source-directory /etc/network/interfaces.d > /etc/network/interfaces
cat <<-CONF > /etc/network/interfaces.d/hinet
# $GENERATED
auto $HINET
iface $HINET inet dhcp
CONF
cat <<-CONF > /etc/network/interfaces.d/localnet
# $GENERATED
allow-hotplug $LOCALNET
iface $LOCALNET inet static
address 192.168.0.20/24

iface $LOCALNET inet static
address 192.168.254.20/24
CONF

####################################################################
echo Installing and configuring dnsmasq
####################################################################
apt-get install --reinstall -y dnsmasq
mkdir -p /etc/dnsmasq.d
cat <<-CONF > /etc/dnsmasq.d/dualnetwork.conf
# $GENERATED
no-negcache
dhcp-range=192.168.0.100,192.168.0.150,4h
interface=$LOCALNET
domain=localnet
dhcp-fqdn
log-dhcp
CONF
systemctl enable --now dnsmasq.service


Edit



This differs from Convert /etc/network/interfaces to netplan for floating IP in that the problem is not netplanning the machine IP addresses; that part is pretty easy. The problem is making the system serve DHCP on one network. When I tried it the obvious way, dnsmasq and systemd-resolved kept stepping on one another's toes. When I tried just disabling systemd-resolvd and letting dnsmasq do all the work it never got the upstream DNS server when it accepted the main network DHCP.





This question is an exact duplicate of:




  • Convert /etc/network/interfaces to netplan for floating IP

    2 answers








networking dhcp netplan systemd-resolved






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 3 at 16:46







Rgaddi

















asked Feb 1 at 22:44









RgaddiRgaddi

162




162




marked as duplicate by Thomas, Charles Green, Eric Carvalho, user2405, Fabby Feb 10 at 21:53


This question was marked as an exact duplicate of an existing question.









marked as duplicate by Thomas, Charles Green, Eric Carvalho, user2405, Fabby Feb 10 at 21:53


This question was marked as an exact duplicate of an existing question.















  • how and why are dnsmasq and systemd-resolved "stepping on one another's toes"? systemd-resolved should only bind to 127.0.0.53 and should be allowed to manage /etc/resolv.conf, which dnsmasq should not need to touch. Where is the toe-stepping happening from dnsmasq?

    – slangasek
    Feb 5 at 0:11











  • @slangasek The problem is that I need dnsmasq to be acting as a DNS resolver to be able to access .localnet resources by name. On my working systems (16.04) dnsmasq takes over ``/etc/resolv.conf``` and points it to 127.0.0.1. Then dnsmasq listens on port 53 to serve DNS. On my non-working 18.04 system, systemd-resolvd points /etc/resolv.conf at 127.0.0.53 as you said. And systemd-resolve --status shows the company DNS server on enp3s0's chain. But when I try to dig local addresses I get "Temporary failure in name resolution"

    – Rgaddi
    Feb 5 at 21:38



















  • how and why are dnsmasq and systemd-resolved "stepping on one another's toes"? systemd-resolved should only bind to 127.0.0.53 and should be allowed to manage /etc/resolv.conf, which dnsmasq should not need to touch. Where is the toe-stepping happening from dnsmasq?

    – slangasek
    Feb 5 at 0:11











  • @slangasek The problem is that I need dnsmasq to be acting as a DNS resolver to be able to access .localnet resources by name. On my working systems (16.04) dnsmasq takes over ``/etc/resolv.conf``` and points it to 127.0.0.1. Then dnsmasq listens on port 53 to serve DNS. On my non-working 18.04 system, systemd-resolvd points /etc/resolv.conf at 127.0.0.53 as you said. And systemd-resolve --status shows the company DNS server on enp3s0's chain. But when I try to dig local addresses I get "Temporary failure in name resolution"

    – Rgaddi
    Feb 5 at 21:38

















how and why are dnsmasq and systemd-resolved "stepping on one another's toes"? systemd-resolved should only bind to 127.0.0.53 and should be allowed to manage /etc/resolv.conf, which dnsmasq should not need to touch. Where is the toe-stepping happening from dnsmasq?

– slangasek
Feb 5 at 0:11





how and why are dnsmasq and systemd-resolved "stepping on one another's toes"? systemd-resolved should only bind to 127.0.0.53 and should be allowed to manage /etc/resolv.conf, which dnsmasq should not need to touch. Where is the toe-stepping happening from dnsmasq?

– slangasek
Feb 5 at 0:11













@slangasek The problem is that I need dnsmasq to be acting as a DNS resolver to be able to access .localnet resources by name. On my working systems (16.04) dnsmasq takes over ``/etc/resolv.conf``` and points it to 127.0.0.1. Then dnsmasq listens on port 53 to serve DNS. On my non-working 18.04 system, systemd-resolvd points /etc/resolv.conf at 127.0.0.53 as you said. And systemd-resolve --status shows the company DNS server on enp3s0's chain. But when I try to dig local addresses I get "Temporary failure in name resolution"

– Rgaddi
Feb 5 at 21:38





@slangasek The problem is that I need dnsmasq to be acting as a DNS resolver to be able to access .localnet resources by name. On my working systems (16.04) dnsmasq takes over ``/etc/resolv.conf``` and points it to 127.0.0.1. Then dnsmasq listens on port 53 to serve DNS. On my non-working 18.04 system, systemd-resolvd points /etc/resolv.conf at 127.0.0.53 as you said. And systemd-resolve --status shows the company DNS server on enp3s0's chain. But when I try to dig local addresses I get "Temporary failure in name resolution"

– Rgaddi
Feb 5 at 21:38










1 Answer
1






active

oldest

votes


















0














Per systemd-resolved.service(8), there are two possible ways to configure systemd-resolved to know about your dnsmasq server:




  • add it to /etc/systemd/resolved.conf as a "global" DNS server

  • add it to a *.network file in one of the directories read by systemd-networkd.


For the latter, it may be sufficient to set a nameservers option in your netplan config for enp2s0, pointing to the local IP that dnsmasq will run on.






share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Per systemd-resolved.service(8), there are two possible ways to configure systemd-resolved to know about your dnsmasq server:




    • add it to /etc/systemd/resolved.conf as a "global" DNS server

    • add it to a *.network file in one of the directories read by systemd-networkd.


    For the latter, it may be sufficient to set a nameservers option in your netplan config for enp2s0, pointing to the local IP that dnsmasq will run on.






    share|improve this answer




























      0














      Per systemd-resolved.service(8), there are two possible ways to configure systemd-resolved to know about your dnsmasq server:




      • add it to /etc/systemd/resolved.conf as a "global" DNS server

      • add it to a *.network file in one of the directories read by systemd-networkd.


      For the latter, it may be sufficient to set a nameservers option in your netplan config for enp2s0, pointing to the local IP that dnsmasq will run on.






      share|improve this answer


























        0












        0








        0







        Per systemd-resolved.service(8), there are two possible ways to configure systemd-resolved to know about your dnsmasq server:




        • add it to /etc/systemd/resolved.conf as a "global" DNS server

        • add it to a *.network file in one of the directories read by systemd-networkd.


        For the latter, it may be sufficient to set a nameservers option in your netplan config for enp2s0, pointing to the local IP that dnsmasq will run on.






        share|improve this answer













        Per systemd-resolved.service(8), there are two possible ways to configure systemd-resolved to know about your dnsmasq server:




        • add it to /etc/systemd/resolved.conf as a "global" DNS server

        • add it to a *.network file in one of the directories read by systemd-networkd.


        For the latter, it may be sufficient to set a nameservers option in your netplan config for enp2s0, pointing to the local IP that dnsmasq will run on.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 6 at 22:30









        slangasekslangasek

        2,55311419




        2,55311419















            Popular posts from this blog

            How to make a Squid Proxy server?

            第一次世界大戦

            Touch on Surface Book