Compare commits

...

No commits in common. "build" and "fabian-poprawione2" have entirely different histories.

21 changed files with 147 additions and 65 deletions

View File

@ -3,16 +3,17 @@
\@writefile{toc}{\contentsline {section}{\numberline {2}Prerequisites}{1}{}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {2}Prerequisites}{1}{}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {3}Step-by-Step Configuration}{1}{}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {3}Step-by-Step Configuration}{1}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.1}Creating and Setting Up the Incus Container}{1}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {3.1}Creating and Setting Up the Incus Container}{1}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.2}Installing Additional Packages}{1}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {3.2}Installing Additional Packages}{2}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.3}Configuring Users and Permissions}{2}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {3.3}Configuring Users and Permissions}{2}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {3.3.1}Changing the Root Password}{2}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsubsection}{\numberline {3.3.1}Changing the Root Password}{2}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{\numberline {3.3.2}Adding a New User}{2}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsubsection}{\numberline {3.3.2}Adding a New User}{2}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.4}Accessing the Container}{2}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {3.4}Accessing the Container}{2}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.5}Installing dnsmasq}{2}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {3.5}Installing dnsmasq}{2}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.6}Configuring the Network with Netplan}{2}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {3.6}Configuring Network with Veth Pairs and Netplan}{3}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.7}Configuring dnsmasq}{3}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {3.7}Configuring the Network with Netplan}{3}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.8}Starting and Enabling dnsmasq}{4}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {3.8}Configuring dnsmasq}{4}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {3.9}Testing the Configuration}{4}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {3.9}Starting and Enabling dnsmasq}{5}{}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {4}Troubleshooting}{4}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {3.10}Testing the Configuration}{5}{}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {5}Conclusion}{4}{}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {4}Troubleshooting}{5}{}\protected@file@percent }
\gdef \@abspage@last{4} \@writefile{toc}{\contentsline {section}{\numberline {5}Conclusion}{6}{}\protected@file@percent }
\gdef \@abspage@last{6}

View File

@ -1,11 +1,11 @@
This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2025/dev/Debian) (preloaded format=pdflatex 2024.12.27) 15 MAY 2025 09:28 This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2025/dev/Debian) (preloaded format=pdflatex 2025.5.15) 15 MAY 2025 11:32
entering extended mode entering extended mode
restricted \write18 enabled. restricted \write18 enabled.
%&-line parsing enabled. %&-line parsing enabled.
**main **main.tex
(./main.tex (./main.tex
LaTeX2e <2024-11-01> LaTeX2e <2024-11-01> patch level 2
L3 programming layer <2024-11-02> L3 programming layer <2025-01-18>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2024/06/29 v1.4n Standard LaTeX document class Document Class: article 2024/06/29 v1.4n Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo (/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo
@ -77,7 +77,7 @@ Package: keyval 2022/05/29 v1.15 key=value parser (DPC)
Package: ifvtex 2019/10/25 v1.7 ifvtex legacy package. Use iftex instead. Package: ifvtex 2019/10/25 v1.7 ifvtex legacy package. Use iftex instead.
(/usr/share/texlive/texmf-dist/tex/generic/iftex/iftex.sty (/usr/share/texlive/texmf-dist/tex/generic/iftex/iftex.sty
Package: iftex 2022/02/03 v1.0f TeX engine tests Package: iftex 2024/12/12 v1.0g TeX engine tests
)) ))
\Gm@cnth=\count270 \Gm@cnth=\count270
\Gm@cntv=\count271 \Gm@cntv=\count271
@ -155,10 +155,10 @@ Package: ltxcmds 2023-12-04 v1.26 LaTeX kernel commands for general use (HO)
Package: kvsetkeys 2022-10-05 v1.19 Key value parser (HO) Package: kvsetkeys 2022-10-05 v1.19 Key value parser (HO)
)) ))
(/usr/share/texlive/texmf-dist/tex/latex/etoolbox/etoolbox.sty (/usr/share/texlive/texmf-dist/tex/latex/etoolbox/etoolbox.sty
Package: etoolbox 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW) Package: etoolbox 2025/02/11 v2.5l e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count281 \etb@tempcnta=\count281
)) ))
LaTeX Font Info: Trying to load font information for T1+lmr on input line 35 LaTeX Font Info: Trying to load font information for T1+lmr on input line 49
. .
(/usr/share/texmf/tex/latex/lm/t1lmr.fd (/usr/share/texmf/tex/latex/lm/t1lmr.fd
@ -172,20 +172,20 @@ File: l3backend-pdftex.def 2024-05-08 L3 backend support: PDF output (pdfTeX)
(./main.aux) (./main.aux)
\openout1 = `main.aux'. \openout1 = `main.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 35. LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 49.
LaTeX Font Info: ... okay on input line 35. LaTeX Font Info: ... okay on input line 49.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 35. LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 49.
LaTeX Font Info: ... okay on input line 35. LaTeX Font Info: ... okay on input line 49.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 35. LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 49.
LaTeX Font Info: ... okay on input line 35. LaTeX Font Info: ... okay on input line 49.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 35. LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 49.
LaTeX Font Info: ... okay on input line 35. LaTeX Font Info: ... okay on input line 49.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 35. LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 49.
LaTeX Font Info: ... okay on input line 35. LaTeX Font Info: ... okay on input line 49.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 35. LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 49.
LaTeX Font Info: ... okay on input line 35. LaTeX Font Info: ... okay on input line 49.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 35. LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 49.
LaTeX Font Info: ... okay on input line 35. LaTeX Font Info: ... okay on input line 49.
*geometry* driver: auto-detecting *geometry* driver: auto-detecting
*geometry* detected driver: pdftex *geometry* detected driver: pdftex
@ -236,43 +236,43 @@ LaTeX Font Info: ... okay on input line 35.
\makeMPintoPDFobject=\count289 \makeMPintoPDFobject=\count289
\everyMPtoPDFconversion=\toks23 \everyMPtoPDFconversion=\toks23
) )
LaTeX Font Info: Trying to load font information for OT1+lmr on input line 4 LaTeX Font Info: Trying to load font information for OT1+lmr on input line 5
0. 4.
(/usr/share/texmf/tex/latex/lm/ot1lmr.fd (/usr/share/texmf/tex/latex/lm/ot1lmr.fd
File: ot1lmr.fd 2015/05/01 v1.6.1 Font defs for Latin Modern File: ot1lmr.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
) )
LaTeX Font Info: Trying to load font information for OML+lmm on input line 4 LaTeX Font Info: Trying to load font information for OML+lmm on input line 5
0. 4.
(/usr/share/texmf/tex/latex/lm/omllmm.fd (/usr/share/texmf/tex/latex/lm/omllmm.fd
File: omllmm.fd 2015/05/01 v1.6.1 Font defs for Latin Modern File: omllmm.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
) )
LaTeX Font Info: Trying to load font information for OMS+lmsy on input line LaTeX Font Info: Trying to load font information for OMS+lmsy on input line
40. 54.
(/usr/share/texmf/tex/latex/lm/omslmsy.fd (/usr/share/texmf/tex/latex/lm/omslmsy.fd
File: omslmsy.fd 2015/05/01 v1.6.1 Font defs for Latin Modern File: omslmsy.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
) )
LaTeX Font Info: Trying to load font information for OMX+lmex on input line LaTeX Font Info: Trying to load font information for OMX+lmex on input line
40. 54.
(/usr/share/texmf/tex/latex/lm/omxlmex.fd (/usr/share/texmf/tex/latex/lm/omxlmex.fd
File: omxlmex.fd 2015/05/01 v1.6.1 Font defs for Latin Modern File: omxlmex.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
) )
LaTeX Font Info: External font `lmex10' loaded for size LaTeX Font Info: External font `lmex10' loaded for size
(Font) <14.4> on input line 40. (Font) <14.4> on input line 54.
LaTeX Font Info: External font `lmex10' loaded for size LaTeX Font Info: External font `lmex10' loaded for size
(Font) <10> on input line 40. (Font) <10> on input line 54.
LaTeX Font Info: External font `lmex10' loaded for size LaTeX Font Info: External font `lmex10' loaded for size
(Font) <7> on input line 40. (Font) <7> on input line 54.
LaTeX Font Info: Trying to load font information for T1+lmtt on input line 4 LaTeX Font Info: Trying to load font information for T1+lmtt on input line 5
3. 7.
(/usr/share/texmf/tex/latex/lm/t1lmtt.fd (/usr/share/texmf/tex/latex/lm/t1lmtt.fd
File: t1lmtt.fd 2015/05/01 v1.6.1 Font defs for Latin Modern File: t1lmtt.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
) )
LaTeX Font Info: Trying to load font information for TS1+lmr on input line 4 LaTeX Font Info: Trying to load font information for TS1+lmr on input line 6
8. 2.
(/usr/share/texmf/tex/latex/lm/ts1lmr.fd (/usr/share/texmf/tex/latex/lm/ts1lmr.fd
File: ts1lmr.fd 2015/05/01 v1.6.1 Font defs for Latin Modern File: ts1lmr.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
@ -283,7 +283,7 @@ File: lstlang1.sty 2024/09/23 1.10c listings language file
(/usr/share/texlive/texmf-dist/tex/latex/listings/lstlang1.sty (/usr/share/texlive/texmf-dist/tex/latex/listings/lstlang1.sty
File: lstlang1.sty 2024/09/23 1.10c listings language file File: lstlang1.sty 2024/09/23 1.10c listings language file
) )
Overfull \hbox (23.59369pt too wide) in paragraph at lines 65--66 Overfull \hbox (23.59369pt too wide) in paragraph at lines 80--81
\T1/lmr/m/n/12 The \T1/lmtt/m/n/12 security.syscalls.intercept.mount\T1/lmr/m/n \T1/lmr/m/n/12 The \T1/lmtt/m/n/12 security.syscalls.intercept.mount\T1/lmr/m/n
/12 , \T1/lmtt/m/n/12 security.nesting\T1/lmr/m/n/12 , and \T1/lmtt/m/n/12 secu /12 , \T1/lmtt/m/n/12 security.nesting\T1/lmr/m/n/12 , and \T1/lmtt/m/n/12 secu
rity.privileged rity.privileged
@ -295,43 +295,50 @@ rity.privileged
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}{/usr/share/texmf/fonts/enc/ {/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}{/usr/share/texmf/fonts/enc/
dvips/lm/lm-ec.enc}{/usr/share/texmf/fonts/enc/dvips/lm/lm-ts1.enc}] dvips/lm/lm-ec.enc}{/usr/share/texmf/fonts/enc/dvips/lm/lm-ts1.enc}]
(/usr/share/texlive/texmf-dist/tex/latex/listings/lstlang1.sty
File: lstlang1.sty 2024/09/23 1.10c listings language file
)
[2] [2]
LaTeX Font Info: Font shape `T1/lmtt/bx/n' in size <10.95> not available
(Font) Font shape `T1/lmtt/b/n' tried instead on input line 117.
Overfull \hbox (25.69144pt too wide) in paragraph at lines 164--165 [3]
LaTeX Font Info: Font shape `T1/lmtt/bx/n' in size <10.95> not available
(Font) Font shape `T1/lmtt/b/n' tried instead on input line 172.
[4]
Overfull \hbox (25.69144pt too wide) in paragraph at lines 237--238
[]\T1/lmtt/m/n/12 dhcp-range\T1/lmr/m/n/12 : De-fines the IP range for DHCP cli []\T1/lmtt/m/n/12 dhcp-range\T1/lmr/m/n/12 : De-fines the IP range for DHCP cli
ents (from 192.168.1.100 to 192.168.1.200, ents (from 192.168.1.100 to 192.168.1.200,
[] []
[3] [5]
[4] (./main.aux) [6] (./main.aux)
*********** ***********
LaTeX2e <2024-11-01> LaTeX2e <2024-11-01> patch level 2
L3 programming layer <2024-11-02> L3 programming layer <2025-01-18>
*********** ***********
) )
Here is how much of TeX's memory you used: Here is how much of TeX's memory you used:
5009 strings out of 473362 5150 strings out of 475178
72806 string characters out of 5723554 74333 string characters out of 5766539
842560 words of memory out of 5000000 825811 words of memory out of 5000000
28076 multiletter control sequences out of 15000+600000 28102 multiletter control sequences out of 15000+600000
598499 words of font info for 61 fonts, out of 8000000 for 9000 599267 words of font info for 61 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191 14 hyphenation exceptions out of 8191
57i,6n,65p,493b,1661s stack positions out of 10000i,1000n,20000p,200000b,200000s 57i,6n,65p,497b,1620s stack positions out of 10000i,1000n,20000p,200000b,200000s
</usr/share/texmf/fonts/type1/public/lm/lmbx12.pfb></usr/share/texmf/fonts/ty </usr/share/texmf/fonts/type1/public/lm/lmbx12.pfb></usr/share/texmf/fonts/ty
pe1/public/lm/lmr12.pfb></usr/share/texmf/fonts/type1/public/lm/lmr17.pfb></usr pe1/public/lm/lmr12.pfb></usr/share/texmf/fonts/type1/public/lm/lmr17.pfb></usr
/share/texmf/fonts/type1/public/lm/lmr6.pfb></usr/share/texmf/fonts/type1/publi /share/texmf/fonts/type1/public/lm/lmr6.pfb></usr/share/texmf/fonts/type1/publi
c/lm/lmtk10.pfb></usr/share/texmf/fonts/type1/public/lm/lmtt10.pfb></usr/share/ c/lm/lmtk10.pfb></usr/share/texmf/fonts/type1/public/lm/lmtt10.pfb></usr/share/
texmf/fonts/type1/public/lm/lmtt12.pfb> texmf/fonts/type1/public/lm/lmtt12.pfb>
Output written on main.pdf (4 pages, 199974 bytes). Output written on main.pdf (6 pages, 206192 bytes).
PDF statistics: PDF statistics:
57 PDF objects out of 1000 (max. 8388607) 63 PDF objects out of 1000 (max. 8388607)
35 compressed objects within 1 object stream 39 compressed objects within 1 object stream
0 named destinations out of 1000 (max. 500000) 0 named destinations out of 1000 (max. 500000)
1 words of extra memory for PDF output out of 10000 (max. 10000000) 1 words of extra memory for PDF output out of 10000 (max. 10000000)

BIN
dnsmasq/doc/main.pdf Normal file

Binary file not shown.

View File

@ -32,6 +32,20 @@
morestring=[b]{'} morestring=[b]{'}
} }
% Define Python language for listings
\lstdefinelanguage{python}{
keywords={def,class,import,from,as,try,except,with,return,raise,if,elif,else,for,in,while,break,continue},
keywordstyle=\color{blue}\bfseries,
basicstyle=\ttfamily\small,
sensitive=true,
comment=[l]{\#},
commentstyle=\color{gray}\itshape,
stringstyle=\color{red},
morestring=[b]{"},
morestring=[b]{'},
identifierstyle=\color{black}
}
\begin{document} \begin{document}
\title{Basic Configuration of dnsmasq in an Incus Container on Debian with Netplan} \title{Basic Configuration of dnsmasq in an Incus Container on Debian with Netplan}
@ -40,13 +54,14 @@
\maketitle \maketitle
\section{Introduction} \section{Introduction}
This guide provides step-by-step instructions for setting up \texttt{dnsmasq} as a DNS and DHCP server in an Incus container running Debian. The network configuration is managed using Netplan to ensure proper network integration. This guide provides step-by-step instructions for setting up \texttt{dnsmasq} as a DNS and DHCP server in an Incus container running Debian. The network configuration is managed using Netplan and a custom Python script to create virtual Ethernet (veth) pairs and bridges, ensuring proper network integration.
\section{Prerequisites} \section{Prerequisites}
Before proceeding, ensure the following: Before proceeding, ensure the following:
\begin{itemize} \begin{itemize}
\item Incus is installed on the host system (\texttt{sudo apt install incus}). \item Incus is installed on the host system (\texttt{sudo apt install incus}).
\item A Debian-based container is created in Incus. \item A Debian-based container is created in Incus.
\item Python 3 and the \texttt{pyroute2} package are installed on the host (\texttt{sudo apt install python3 python3-pyroute2}).
\item Basic knowledge of Linux networking and container management. \item Basic knowledge of Linux networking and container management.
\item Root or sudo access to the host and container. \item Root or sudo access to the host and container.
\end{itemize} \end{itemize}
@ -107,8 +122,48 @@ incus exec dnsmasq-container -- apt update
incus exec dnsmasq-container -- apt install dnsmasq -y incus exec dnsmasq-container -- apt install dnsmasq -y
\end{lstlisting} \end{lstlisting}
\subsection{Configuring Network with Veth Pairs and Netplan}
To enable advanced networking, use the provided Python script (\texttt{link.py}) to create a virtual Ethernet (veth) pair connecting the container to the host's network namespace, with an optional bridge for network integration. Save the following script as \texttt{link.py} on the host:
\begin{lstlisting}[language=python]
import argparse
import os
import subprocess
import sys
from pyroute2 import IPRoute, NetNS
# ... (rest of the link.py script as provided) ...
\end{lstlisting}
Run the script to create a veth pair, move one end to the container's network namespace, and attach it to a bridge on the host. First, identify the container's name or ID:
\begin{lstlisting}[language=bash]
incus list
\end{lstlisting}
Assuming the container name is \texttt{dnsmasq-container}, execute the script with sudo privileges:
\begin{lstlisting}[language=bash]
sudo python3 link.py -t1 incus -ns1 dnsmasq-container -n1 veth-container -t2 1 -n2 veth-host -b2 br0
\end{lstlisting}
\textbf{Explanation:}
\begin{itemize}
\item \texttt{-t1 incus}: Specifies that the first namespace is an Incus container.
\item \texttt{-ns1 dnsmasq-container}: Specifies the container's network namespace (Incus container name).
\item \texttt{-n1 veth-container}: Names the veth interface inside the container.
\item \texttt{-t2 1}: Specifies the default (host) namespace.
\item \texttt{-n2 veth-host}: Names the veth interface on the host.
\item \texttt{-b2 br0}: Attaches the host's veth interface to a bridge named \texttt{br0}.
\end{itemize}
Before running the script, ensure the bridge \texttt{br0} exists on the host. Create it if necessary:
\begin{lstlisting}[language=bash]
sudo ip link add name br0 type bridge
sudo ip link set br0 up
\end{lstlisting}
The script exposes the container's network namespace, creates the veth pair, moves \texttt{veth-container} to the container's namespace, attaches \texttt{veth-host} to \texttt{br0}, and brings both interfaces up.
\subsection{Configuring the Network with Netplan} \subsection{Configuring the Network with Netplan}
Configure the container's network using Netplan to assign a static IP address. Create or edit the Netplan configuration file at \texttt{/etc/netplan/01-netcfg.yaml}: Configure the container's network using Netplan to assign a static IP address to the \texttt{veth-container} interface (aliased as \texttt{eth0} for simplicity). Create or edit the Netplan configuration file at \texttt{/etc/netplan/01-netcfg.yaml} inside the container:
\begin{lstlisting}[language=bash] \begin{lstlisting}[language=bash]
incus exec dnsmasq-container -- nano /etc/netplan/01-netcfg.yaml incus exec dnsmasq-container -- nano /etc/netplan/01-netcfg.yaml
\end{lstlisting} \end{lstlisting}
@ -118,6 +173,8 @@ network:
version: 2 version: 2
ethernets: ethernets:
eth0: eth0:
match:
name: veth-container
dhcp4: no dhcp4: no
addresses: addresses:
- 192.168.1.10/24 - 192.168.1.10/24
@ -127,11 +184,27 @@ network:
nameservers: nameservers:
addresses: [8.8.8.8, 8.8.4.4] addresses: [8.8.8.8, 8.8.4.4]
\end{lstlisting} \end{lstlisting}
\textbf{Explanation:}
\begin{itemize}
\item \texttt{match: name: veth-container}: Matches the \texttt{veth-container} interface created by the script, aliased as \texttt{eth0}.
\item \texttt{dhcp4: no}: Disables DHCP to use a static IP.
\item \texttt{addresses}: Assigns the static IP \texttt{192.168.1.10/24}.
\item \texttt{routes}: Sets the default gateway to \texttt{192.168.1.1}.
\item \texttt{nameservers}: Specifies Google's DNS servers.
\end{itemize}
Apply the configuration: Apply the configuration:
\begin{lstlisting}[language=bash] \begin{lstlisting}[language=bash]
incus exec dnsmasq-container -- netplan apply incus exec dnsmasq-container -- netplan apply
\end{lstlisting} \end{lstlisting}
Verify the network configuration:
\begin{lstlisting}[language=bash]
incus exec dnsmasq-container -- ip a show eth0
incus exec dnsmasq-container -- ping 8.8.8.8
\end{lstlisting}
\subsection{Configuring dnsmasq} \subsection{Configuring dnsmasq}
Edit the \texttt{dnsmasq} configuration file at \texttt{/etc/dnsmasq.conf}: Edit the \texttt{dnsmasq} configuration file at \texttt{/etc/dnsmasq.conf}:
\begin{lstlisting}[language=bash] \begin{lstlisting}[language=bash]
@ -181,7 +254,7 @@ Test DNS resolution from within the container:
\begin{lstlisting}[language=bash] \begin{lstlisting}[language=bash]
incus exec dnsmasq-container -- nslookup example.local 192.168.1.10 incus exec dnsmasq-container -- nslookup example.local 192.168.1.10
\end{lstlisting} \end{lstlisting}
To test DHCP, connect a client device to the same network and verify that it receives an IP address in the range \texttt{192.168.1.100--192.168.1.200}. To test DHCP, connect a client device to the same network (via the \texttt{br0} bridge) and verify that it receives an IP address in the range \texttt{192.168.1.100--192.168.1.200}.
\section{Troubleshooting} \section{Troubleshooting}
If \texttt{dnsmasq} fails to start: If \texttt{dnsmasq} fails to start:
@ -189,9 +262,10 @@ If \texttt{dnsmasq} fails to start:
\item Check the logs: \texttt{incus exec dnsmasq-container -- journalctl -u dnsmasq}. \item Check the logs: \texttt{incus exec dnsmasq-container -- journalctl -u dnsmasq}.
\item Ensure no other service is using port 53 (DNS) or 67 (DHCP). \item Ensure no other service is using port 53 (DNS) or 67 (DHCP).
\item Verify the network configuration with \texttt{incus exec dnsmasq-container -- ip a} and \texttt{incus exec dnsmasq-container -- ping 8.8.8.8}. \item Verify the network configuration with \texttt{incus exec dnsmasq-container -- ip a} and \texttt{incus exec dnsmasq-container -- ping 8.8.8.8}.
\item Confirm the veth pair and bridge setup: \texttt{ip link show} on the host and \texttt{incus exec dnsmasq-container -- ip link show}.
\end{itemize} \end{itemize}
\section{Conclusion} \section{Conclusion}
This guide configures \texttt{dnsmasq} as a DNS and DHCP server in an Incus container on Debian. The Netplan configuration ensures proper network setup. For advanced configurations, refer to the \texttt{dnsmasq} documentation (\texttt{man dnsmasq}). This guide configures \texttt{dnsmasq} as a DNS and DHCP server in an Incus container on Debian. The \texttt{link.py} script and Netplan configuration ensure a robust network setup with veth pairs and static IP addressing. For advanced configurations, refer to the \texttt{dnsmasq} documentation (\texttt{man dnsmasq}) and \texttt{pyroute2} documentation.
\end{document} \end{document}

Binary file not shown.