Last active
August 2, 2017 19:59
-
-
Save tad-lispy/6a3fb8879bbdc6e81925daf5bba8e06c to your computer and use it in GitHub Desktop.
Setup LXD with DNS name resolution on Ubuntu 16.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\t\n' | |
set -x | |
export DEBIAN_FRONTEND=noninteractive | |
# Install newer version of LXD | |
# See https://stgraber.org/2016/10/27/network-management-with-lxd-2-3/#comment-244979 | |
apt-get install --yes --quiet --target-release=xenial-backports lxd | |
lxd init --auto | |
lxc network create lxdbr0 \ | |
ipv4.address=auto \ | |
ipv4.nat=true \ | |
ipv6.address=auto \ | |
ipv6.nat=true | |
lxc network attach-profile lxdbr0 default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\t\n' | |
set -x | |
export DEBIAN_FRONTEND=noninteractive | |
apt-get install --yes --quiet dnsmasq | |
lxd_bridge="lxdbr0" | |
lxd_ipv4_addr="$( | |
lxc network get "${lxd_bridge}" ipv4.address | | |
cut \ | |
--delimiter='/' \ | |
--fields=1 | |
)" | |
# Create dnsmasq configuration from template | |
echo " | |
# Tell any system-wide dnsmasq instance to make sure to bind to interfaces | |
# instead of listening on 0.0.0.0 | |
# WARNING: changes to this file will get lost if lxd is removed. | |
server=/lxd/${lxd_ipv4_addr} | |
bind-interfaces | |
except-interface=${lxd_bridge} | |
" > /etc/dnsmasq.d/lxd | |
systemctl restart dnsmasq.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment