forked from server/user-documentation
Improvements to writes to config files - as discussed in Fedora Server meeting. We opted not to use HEREDOC, and to not specify which editor to use. I also took the opportunity to do some further clarification on variable substitutions.
This commit is contained in:
parent
2f360f7221
commit
5a2fd40aea
1 changed files with 47 additions and 34 deletions
|
|
@ -112,26 +112,27 @@ The example here uses 2 interfaces, an external public interface enp1s0 (public.
|
|||
|
||||
1. **Activate the dnsmasq NetworkManager plugin**
|
||||
+
|
||||
[source,console]
|
||||
Create and edit the file at `/etc/NetworkManager/conf.d/00-use-dnsmasq.conf` using your preferred editor running under sudo with root privileges. The content should be as follows:
|
||||
+
|
||||
[source, ini]
|
||||
----
|
||||
$ sudo tee /etc/NetworkManager/conf.d/00-use-dnsmasq.conf << 'EOF'
|
||||
# /etc/NetworkManager/conf.d/00-use-dnsmasq.conf
|
||||
# This enables the dnsmasq plugin.
|
||||
[main]
|
||||
dns=dnsmasq
|
||||
EOF
|
||||
----
|
||||
|
||||
2. **Configuration of the name resolution (DNS) for the internal private network (internal.lan)**
|
||||
+
|
||||
[source,console]
|
||||
Create and edit the file at `/etc/NetworkManager/dnsmasq.d/01-DNS-<INTERNAL>.conf` using your preferred editor running under sudo with root privileges. The content should be as follows:
|
||||
+
|
||||
[source,ini]
|
||||
----
|
||||
$ sudo tee /etc/NetworkManager/dnsmasq.d/01-DNS-<INTERNAL>.conf << 'EOF'
|
||||
# /etc/NetworkManager/dnsmasq.d/01-DNS-<INTERNAL>.conf
|
||||
# This file sets up DNS for the private local net domain '<INTERNAL>.lan'
|
||||
local=/<INTERNAL>.lan/
|
||||
# file where to find the list of IP - hostname mapping
|
||||
addn-hosts=/etc/dnsmasq-<INTERNAL>.hosts
|
||||
# /etc/NetworkManager/dnsmasq.d/01-DNS-<INTERNAL>.conf
|
||||
# This file sets up DNS for the private local net domain '<INTERNAL>.lan'
|
||||
local=/<INTERNAL>.lan/
|
||||
# file where to find the list of IP - hostname mapping
|
||||
addn-hosts=/etc/dnsmasq-<INTERNAL>.hosts
|
||||
|
||||
domain-needed
|
||||
bogus-priv
|
||||
|
|
@ -149,9 +150,12 @@ no-poll
|
|||
server=<uuu.vv.xx.yy>
|
||||
server=<www.vv.xx.zz>
|
||||
server=<2001:www:xxx:yyy::zz>
|
||||
EOF
|
||||
----
|
||||
+
|
||||
Substitute values for <INTERNAL>, <ENPxyz> with a name for your internal private network, and the network interface connected to your internal private network.
|
||||
+
|
||||
Substitute the values for <uuu.vv.xx.yy>, <www.vv.xx.zz>, and <2001:www:xxx:yyy::zz> with the IP addresses of any upstream DNS servers.
|
||||
+
|
||||
Provide an empty host file
|
||||
+
|
||||
[source,console]
|
||||
|
|
@ -161,9 +165,10 @@ $ sudo touch /etc/dnsmasq-<INTERNAL>.hosts
|
|||
|
||||
3. **Configuration of the DHCP service for the internal private network (<INTERNAL>.lan)**
|
||||
+
|
||||
[source,console]
|
||||
Create and edit the file at `/etc/NetworkManager/dnsmasq.d/02-DHCP-<INTERNAL>.conf` using your preferred editor running under sudo with root privileges. The content should be as follows:
|
||||
+
|
||||
[source,ini]
|
||||
----
|
||||
$ sudo tee /etc/NetworkManager/dnsmasq.d/02-DHCP-<INTERNAL>.conf << 'EOF'
|
||||
# etc/NetworkManager/dnsmasq.d/02-DHCP-<INTERNAL>.conf
|
||||
# This file sets up DHCP for the private local net domain '<INTERNAL>.lan'
|
||||
|
||||
|
|
@ -182,7 +187,7 @@ interface=<ENPxyz>
|
|||
# 28: broadcast address
|
||||
|
||||
dhcp-authoritative
|
||||
dhcp-option=1,<255.255.255.24>
|
||||
dhcp-option=1,<255.255.255.0>
|
||||
dhcp-option=3,<www.xxx.yy.zz>
|
||||
dhcp-option=6,<www.xx.yy.z>
|
||||
|
||||
|
|
@ -193,19 +198,27 @@ dhcp-option=6,<www.xx.yy.z>
|
|||
# Assign dynamically IP addresses to interface to listen on
|
||||
# Range for distributed addresses, tagged <int> for further references
|
||||
dhcp-range=tag:<ENPxyz>,<vvv.ww.xx.y,vvv.ww.xx.z>,24h
|
||||
EOF
|
||||
----
|
||||
+ The example shows the binding of the network interface and then sets the different DHCP responses for various client request options.
|
||||
+ The subnet mask (dhcp-option=1) is set to <255.255.255.24>, the default router or gateway (dhcp-option=3) is set to <www.xxx.yy.zz>, and the DNS server (dhcp-option=6) is set to <www.xx.yy.z>. Substitute values appropriate to your network.
|
||||
+ In this example, no permanent or fixed IP addresses are assigned, but examples are provided as commented lines, so that you can see how to add an entry to assign a particular IP address to a host based on it's MAC address.
|
||||
+ The example enables a DHCP range within the network and assigns hosts IP addresses from <vvv.ww.xx.y> to <vvv.ww.xx.z> with leases lasting for 24 hours.
|
||||
+
|
||||
Substitute values for <INTERNAL>, <ENPxyz> with a name for your internal private network, and the network interface connected to your internal private network.
|
||||
+
|
||||
Substitute the value of <uuu.vv.xx.y/24> with the network address and mask for your internal private network.
|
||||
+
|
||||
The example shows the binding of the network interface and then sets the different DHCP responses for various client request options.
|
||||
+
|
||||
The subnet mask (dhcp-option=1) is set to <255.255.255.0>, the default router or gateway (dhcp-option=3) is set to <www.xxx.yy.zz>, and the DNS server (dhcp-option=6) is set to <www.xx.yy.z>. Substitute values appropriate to your network.
|
||||
+
|
||||
In this example, no permanent or fixed IP addresses are assigned, but examples are provided as commented lines, so that you can see how to add an entry to assign a particular IP address to a host based on it's MAC address.
|
||||
+
|
||||
The example enables a DHCP range within the network and assigns hosts IP addresses from <vvv.ww.xx.y> to <vvv.ww.xx.z> with leases lasting for 24 hours. Substitute values as appropriate for your network.
|
||||
|
||||
4. **Configuration of the DHCP service for the public network (<PUBLIC.TLD>)**
|
||||
+
|
||||
[source,console]
|
||||
Create and edit the file at `/etc/NetworkManager/dnsmasq.d/03-DHCP-<PUBLIC.TLD>.conf` using your preferred editor running under sudo with root privileges. The content should be as follows:
|
||||
+
|
||||
[source,ini]
|
||||
----
|
||||
$ sudo tee /etc/NetworkManager/dnsmasq.d/03-DHCP-<PUBLIC>.conf << 'EOF'
|
||||
# etc/NetworkManager/dnsmasq.d/03-DHCP-<PUBLIC>.conf
|
||||
# etc/NetworkManager/dnsmasq.d/03-DHCP-<PUBLIC.TLD>.conf
|
||||
# This file sets up DHCP for the public '<PUBLIC.TLD>' domain interface
|
||||
|
||||
# The domain the DHCP part of dnsmasq is responsible for:
|
||||
|
|
@ -232,9 +245,14 @@ dhcp-option=tag:<ENPuvw>,option=router,<uuu.vv.ww.zz>
|
|||
# dhcp-host=52:54:00:42:6a:43,apollon,10.10.10.51,infinite
|
||||
# Assign dynamically IP addresses to interface to listen on
|
||||
# Range for distributed addresses, tagged <int> for further references dhcp-range=tag:<ENPuvw>,<uuu.vvv.w.x,uuu.vvv.w.y6,1h
|
||||
EOF
|
||||
----
|
||||
+
|
||||
Substitute values for <PUBLIC.TLD>, <ENPuvw> with the domain name for your public facing network, and the network interface connected to your public facing network.
|
||||
+
|
||||
Substitute the value of <uuu.vv.ww.xx/24> with the network address and mask for your public facing network.
|
||||
+
|
||||
Substitute the value <uuu.vv.ww.zz> with the IP address of the network router or default gateway.
|
||||
+
|
||||
There is no DNS configuration for the external interface following, assuming that a official public DNS server is used to resolve all public facing interfaces of the domain public.tld.
|
||||
|
||||
5. **Test the dnsmasq configuration**
|
||||
|
|
@ -368,34 +386,29 @@ This method is much clearer, improves maintainability and reduces sources of pot
|
|||
== Integrate libvirt's virtual interface
|
||||
In case libvirt and virtualization including a virtual network for the virtual machines, libvirt installs and configures its own dnsmasq instance. In most cases it is just convenient, instead of replacing the libvirt _default_ network to integrate it in NetworkManagers dnsmasq plugin. Thus, two instances of dnsmasq operate along each other.
|
||||
|
||||
To make it work, just add another configuration file. The example uses libvirt.lan as the libvirt virtual network domain name. Adjust as appropriate.
|
||||
To make it work, just add another configuration file, for example `/etc/NetworkManager/dnsmasq.d/30-DNS-libvirt.conf`.
|
||||
|
||||
The example uses libvirt.lan as the libvirt virtual network domain name. Adjust as appropriate.
|
||||
|
||||
We just add the name resolution (DNS) for the libvirt virtual network (libvirt.lan), leaving the DHCP functionality untouched.
|
||||
|
||||
[source,console]
|
||||
[source,ini]
|
||||
----
|
||||
$ sudo tee /etc/NetworkManager/dnsmasq.d/30-DNS-libvirt.conf << 'EOF'
|
||||
# /etc/NetworkManager/dnsmasq.d/30-DNS-libvirt.conf
|
||||
|
||||
# This file directs dnsmasq to forward any request to resolve
|
||||
# names under the .libvirt.lan domain to 192.168.122.1, the
|
||||
# local libvirt DNS server default address.
|
||||
server=/libvirt.lan/192.168.122.1
|
||||
EOF
|
||||
----
|
||||
|
||||
== Managing static DNS Entries
|
||||
|
||||
1. Edit the dnsmasq host file
|
||||
1. **Edit the dnsmasq host file that you created at `/etc/dnsmasq-<INTERNAL>.hosts` to define internal DNS mappings for hosts on the local network.**
|
||||
+
|
||||
The format is the same as /etc/hosts. See the hosts(5) man page for more information.
|
||||
+
|
||||
[source,console]
|
||||
----
|
||||
$ sudo vim /etc/dnsmasq-<INTERNAL>.hosts
|
||||
----
|
||||
|
||||
2. Restart NetworkManager to read the modified file.
|
||||
2. **Restart NetworkManager to read the modified file.**
|
||||
+
|
||||
[source,console]
|
||||
----
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue