Allow-listing web traffic – blocking all web traffic that has not been pre-approved – is a common practice in highly sensitive environments. It is also a challenge for developers and system administrators working in those environments. In this blog, we’ll cover an easy way to mitigate this challenge by using LXD to generate allow-lists.
Many applications, tools, and websites pull packages, configurations, and other data from domains that the end user never sees, unless they happen to monitor the associated network traffic. Trying to perform a new operation in an allow-listed environment usually follows an unfortunate pattern:
The best method to avoid this ‘vicious cycle’ of allow-listing is to pre-identify all required resources by executing your process in an unconstrained environment while monitoring network traffic. After the process has been executed start-to-finish, an allow-list can be generated from network logs with confidence that the result includes all required resources.
In the context of domain-based allow-listing, DNS logs are the most direct method of monitoring – and, fortunately, Canonical’s LXD makes it easy to create a test environment with DNS logging.
When setting up LXD with default configurations (lxd init --minimal), LXD will create a managed bridge network. This network type supports DHCP and DNS with no extra configuration. LXD does this by running an instance of dnsmasq in the background.
Even better, LXD allows us to customize the configuration of the dnsmasq server via the raw.dnsmasq configuration option. The relevant configuration options for our use case are:
log-queries – log DNS querieslog-facility= – write logs to the specified filepathquiet-dhcp – suppress standard DHCP loggingquiet-dhcp6 – suppress standard DHCP6 logginglxc network ls --format json | jq -r '.[] | select(.managed) | .name' The returned names are managed networks. If the command does not return any output, create a new managed network with lxc network create YOUR_NETWORK_NAME
lxc network set YOUR_NETWORK_NAME raw.dnsmasq "$(echo -e 'log-queriesnlog-facility=/tmp/dns.lognquiet-dhcpnquiet-dhcp6')" lxc show network YOUR_NETWORK_NAMElxc launch ubuntu:24.04 dnstest -n YOUR_NETWORK_NAME lxc exec dnstest -- su ubuntu
nslookup google.com
nslookup canonical.com sudo grep -oP 'query[A+]sKS+' /tmp/snap-private-tmp/snap.lxd/tmp/dns.log | sort -u By following this process, one can generate a complete list of domains used by any process executed within an LXD virtual machine or container. That list of domains can be formatted as an allow-list configuration file, avoiding the iterative cycle all too common with manual approaches.
Open source thrives on engineering-driven processes. Fast feedback loops, terminal tools, Git workflows: they’re the…
I’ve yet to meet a developer that enjoys working with metered AI APIs. The need…
A local privilege escalation (LPE) security vulnerability in the Linux kernel, codename “PinTheft,” was publicly…
Canonical, the publisher of Ubuntu, today announced the general availability (GA) of Managed Kubeflow on…
Welcome to this blog series which explores innovative uses of Ubuntu Core. Throughout this series,…
An information disclosure security vulnerability in the Linux kernel was publicly disclosed on May 15th,…