Browse Source

fix gateway as resoler

main
pvincent 7 months ago
parent
commit
83522d6692
  1. 20
      lib/install.sh
  2. 4
      scripts/lxc-miaou-create

20
lib/install.sh

@ -3,7 +3,11 @@
MIAOU_BASEDIR=$(readlink -f "$(dirname "$0")/..") MIAOU_BASEDIR=$(readlink -f "$(dirname "$0")/..")
# shellcheck source=/dev/null # shellcheck source=/dev/null
. "$MIAOU_BASEDIR/lib/functions.sh" . "$MIAOU_BASEDIR/lib/functions.sh"
readonly MIAOU_BASEDIR
FDN_DOMAINNAME=fdn.fr
FDN_RESOLVER=80.67.169.12
readonly MIAOU_BASEDIR FDN_DOMAINNAME FDN_RESOLVER
miaou_init miaou_init
@ -367,6 +371,16 @@ function miaou_resolver() {
bridge=$(ip addr show lxdbr0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1) bridge=$(ip addr show lxdbr0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
gateway=$(ip route | grep default | cut -d' ' -f3) gateway=$(ip route | grep default | cut -d' ' -f3)
echo -n "test gateway <$gateway> as DNS resolver..."
if dig +short "@$gateway" "$FDN_DOMAINNAME" >/dev/null; then
resolver="$gateway"
PREFIX="" echoinfo DONE
else
PREFIX="" echowarn FAILED
echo "resolver replaced by FDN_RESOLVER=<$FDN_RESOLVER>"
resolver="$FDN_RESOLVER"
fi
if command -v nmcli &>/dev/null; then if command -v nmcli &>/dev/null; then
if [[ ! -f /etc/NetworkManager/dispatcher.d/50-miaou-resolver ]]; then if [[ ! -f /etc/NetworkManager/dispatcher.d/50-miaou-resolver ]]; then
echo -n "use NetworkManager dispatcher to deal with LXD bridge automatically..." echo -n "use NetworkManager dispatcher to deal with LXD bridge automatically..."
@ -388,11 +402,11 @@ function miaou_resolver() {
fi fi
if ! grep -q "nameserver $bridge" /etc/resolv.conf; then if ! grep -q "nameserver $bridge" /etc/resolv.conf; then
echo -n "customize resolv.conf from scratch with bridge=<$bridge>, gatewary=<$gateway> ..."
echo -n "customize resolv.conf from scratch with bridge=<$bridge>, resolver=<$resolver> ..."
sudo tee /etc/resolv.conf &>/dev/null <<EOF sudo tee /etc/resolv.conf &>/dev/null <<EOF
# generated by miaou # generated by miaou
nameserver $bridge # LXD bridge nameserver $bridge # LXD bridge
nameserver $gateway # gateway
nameserver $resolver # resolver
EOF EOF
PREFIX="" echoinfo DONE PREFIX="" echoinfo DONE
else else

4
scripts/lxc-miaou-create

@ -58,8 +58,8 @@ function create() {
[[ "$OPTION_SSH" == true ]] && packages+=(openssh-server) [[ "$OPTION_SSH" == true ]] && packages+=(openssh-server)
packages_string=$(join ', ' "${packages[@]}") packages_string=$(join ', ' "${packages[@]}")
timezone='Indian/Reunion' #FIXME: should be retrieved from host
debian_repo='debian.mithril.re' #FIXME: should be retrieved from host
timezone=$(cat /etc/timezone)
debian_repo=$(cat /etc/apt/sources.list | head -n1 | cut -d '/' -f3)
user_data="$( user_data="$(
cat <<EOF cat <<EOF

Loading…
Cancel
Save