replaced dnsmasq-container -> deb2
This commit is contained in:
parent
444cc9f004
commit
0af7be8bcf
54
doc/main.tex
54
doc/main.tex
@ -54,21 +54,21 @@ Before proceeding, ensure the following:
|
||||
\section{Step-by-Step Configuration}
|
||||
|
||||
\subsection{Creating and Setting Up the Incus Container}
|
||||
Create a Debian container named \texttt{dnsmasq-container} using the following commands on the host:
|
||||
Create a Debian container named \texttt{deb2} using the following commands on the host:
|
||||
\begin{lstlisting}[language=bash]
|
||||
incus create images:debian/12 dnsmasq-container
|
||||
incus config set dnsmasq-container security.syscalls.intercept.mount true
|
||||
incus config set dnsmasq-container security.nesting true
|
||||
incus config set dnsmasq-container security.privileged true
|
||||
incus start dnsmasq-container
|
||||
incus create images:debian/12 deb2
|
||||
incus config set deb2 security.syscalls.intercept.mount true
|
||||
incus config set deb2 security.nesting true
|
||||
incus config set deb2 security.privileged true
|
||||
incus start deb2
|
||||
\end{lstlisting}
|
||||
The \texttt{security.syscalls.intercept.mount}, \texttt{security.nesting}, and \texttt{security.privileged} settings are required for \texttt{dnsmasq} and Docker to function correctly in the container.
|
||||
|
||||
\subsection{Installing Additional Packages}
|
||||
Install the necessary packages inside the container:
|
||||
\begin{lstlisting}[language=bash]
|
||||
incus exec dnsmasq-container -- apt update
|
||||
incus exec dnsmasq-container -- apt install -y \
|
||||
incus exec deb2 -- apt update
|
||||
incus exec deb2 -- apt install -y \
|
||||
netplan.io \
|
||||
sudo vim nano git tmux mc zip unzip curl wget htop lynx \
|
||||
iproute2 termshark bridge-utils \
|
||||
@ -82,23 +82,23 @@ Configure user access and permissions within the container.
|
||||
\subsubsection{Changing the Root Password}
|
||||
Set the root password to "passroot":
|
||||
\begin{lstlisting}[language=bash]
|
||||
incus exec dnsmasq-container -- bash -c 'echo "root:passroot" | chpasswd'
|
||||
incus exec deb2 -- bash -c 'echo "root:passroot" | chpasswd'
|
||||
\end{lstlisting}
|
||||
|
||||
\subsubsection{Adding a New User}
|
||||
Add a new user named "user" with the password "pass" and add them to the "sudo" and "docker" groups:
|
||||
\begin{lstlisting}[language=bash]
|
||||
incus exec dnsmasq-container -- useradd -m -s /bin/bash user
|
||||
incus exec dnsmasq-container -- bash -c 'echo "user:pass" | chpasswd'
|
||||
incus exec dnsmasq-container -- usermod -aG sudo user
|
||||
incus exec dnsmasq-container -- usermod -aG docker user
|
||||
incus exec deb2 -- useradd -m -s /bin/bash user
|
||||
incus exec deb2 -- bash -c 'echo "user:pass" | chpasswd'
|
||||
incus exec deb2 -- usermod -aG sudo user
|
||||
incus exec deb2 -- usermod -aG docker user
|
||||
\end{lstlisting}
|
||||
|
||||
After creating the user, you can also transfer configuration files such as \texttt{.tmux.conf} and \texttt{.vimrc} from your local machine to the home directory of the newly created user inside the container:
|
||||
|
||||
\begin{lstlisting}[language=bash]
|
||||
incus file push .tmux.conf dnsmasq-container/home/user/
|
||||
incus file push .vimrc dnsmasq-container/home/user/
|
||||
incus file push .tmux.conf deb2/home/user/
|
||||
incus file push .vimrc deb2/home/user/
|
||||
\end{lstlisting}
|
||||
|
||||
To enhance the functionality of Vim, it's recommended to install a plugin manager such as \texttt{vim-plug}. This can be done by downloading the plugin manager directly into the user's Vim configuration directory using the following command:
|
||||
@ -111,20 +111,20 @@ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \\
|
||||
\subsection{Accessing the Container}
|
||||
Access the container's shell:
|
||||
\begin{lstlisting}[language=bash]
|
||||
incus exec dnsmasq-container -- bash
|
||||
incus exec deb2 -- bash
|
||||
\end{lstlisting}
|
||||
|
||||
\subsection{Installing dnsmasq}
|
||||
Update the package list and install \texttt{dnsmasq}:
|
||||
\begin{lstlisting}[language=bash]
|
||||
incus exec dnsmasq-container -- apt update
|
||||
incus exec dnsmasq-container -- apt install dnsmasq -y
|
||||
incus exec deb2 -- apt update
|
||||
incus exec deb2 -- apt install dnsmasq -y
|
||||
\end{lstlisting}
|
||||
|
||||
\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}:
|
||||
\begin{lstlisting}[language=bash]
|
||||
incus exec dnsmasq-container -- nano /etc/netplan/01-netcfg.yaml
|
||||
incus exec deb2 -- nano /etc/netplan/01-netcfg.yaml
|
||||
\end{lstlisting}
|
||||
Add the following configuration:
|
||||
\begin{lstlisting}[language=yaml]
|
||||
@ -143,13 +143,13 @@ network:
|
||||
\end{lstlisting}
|
||||
Apply the configuration:
|
||||
\begin{lstlisting}[language=bash]
|
||||
incus exec dnsmasq-container -- netplan apply
|
||||
incus exec deb2 -- netplan apply
|
||||
\end{lstlisting}
|
||||
|
||||
\subsection{Configuring dnsmasq}
|
||||
Edit the \texttt{dnsmasq} configuration file at \texttt{/etc/dnsmasq.conf}:
|
||||
\begin{lstlisting}[language=bash]
|
||||
incus exec dnsmasq-container -- nano /etc/dnsmasq.conf
|
||||
incus exec deb2 -- nano /etc/dnsmasq.conf
|
||||
\end{lstlisting}
|
||||
Add or modify the following settings to enable DNS and DHCP:
|
||||
\begin{lstlisting}
|
||||
@ -182,27 +182,27 @@ dhcp-option=6,8.8.8.8,8.8.4.4
|
||||
\subsection{Starting and Enabling dnsmasq}
|
||||
Restart and enable the \texttt{dnsmasq} service:
|
||||
\begin{lstlisting}[language=bash]
|
||||
incus exec dnsmasq-container -- systemctl restart dnsmasq
|
||||
incus exec dnsmasq-container -- systemctl enable dnsmasq
|
||||
incus exec deb2 -- systemctl restart dnsmasq
|
||||
incus exec deb2 -- systemctl enable dnsmasq
|
||||
\end{lstlisting}
|
||||
Verify that \texttt{dnsmasq} is running:
|
||||
\begin{lstlisting}[language=bash]
|
||||
incus exec dnsmasq-container -- systemctl status dnsmasq
|
||||
incus exec deb2 -- systemctl status dnsmasq
|
||||
\end{lstlisting}
|
||||
|
||||
\subsection{Testing the Configuration}
|
||||
Test DNS resolution from within the container:
|
||||
\begin{lstlisting}[language=bash]
|
||||
incus exec dnsmasq-container -- nslookup example.local 192.168.1.10
|
||||
incus exec deb2 -- nslookup example.local 192.168.1.10
|
||||
\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}.
|
||||
|
||||
\section{Troubleshooting}
|
||||
If \texttt{dnsmasq} fails to start:
|
||||
\begin{itemize}
|
||||
\item Check the logs: \texttt{incus exec dnsmasq-container -- journalctl -u dnsmasq}.
|
||||
\item Check the logs: \texttt{incus exec deb2 -- journalctl -u dnsmasq}.
|
||||
\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 deb2 -- ip a} and \texttt{incus exec deb2 -- ping 8.8.8.8}.
|
||||
\end{itemize}
|
||||
|
||||
\section{Conclusion}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user