From 01b94b32ee22459d2a0664e9b2825ab1b1fdb57e Mon Sep 17 00:00:00 2001 From: Aofei Sheng Date: Sat, 19 Nov 2022 13:00:01 +0800 Subject: [PATCH] Replace dhclient with systemd-networkd Fixes #45, #49 --- README.md | 2 +- build-arch-gce | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 13e5719..13d7637 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Arch Linux installation are the following: machines. - Root filesystem is ext4. - Locale is set to en_US.UTF-8 and timezone is set to UTC. -- Network is configured through dhclient. +- Network is configured through systemd-networkd. - Systemd-timesyncd is enabled and configured to use the Compute Engine metadata server. - Pacman keyring is configured to be built and initialized on first boot. diff --git a/build-arch-gce b/build-arch-gce index 0103378..7d27297 100755 --- a/build-arch-gce +++ b/build-arch-gce @@ -76,7 +76,7 @@ append_gce_repo() { cp /etc/pacman.conf "$work_dir" append_gce_repo "$work_dir/pacman.conf" pacstrap -G -M -C "$work_dir/pacman.conf" -- "$mount_dir" \ - base linux dosfstools e2fsprogs dhclient openssh sudo google-compute-engine + base linux dosfstools e2fsprogs openssh sudo google-compute-engine append_gce_repo "$mount_dir/etc/pacman.conf" echo '- Configuring fstab.' @@ -113,6 +113,22 @@ arch-chroot -- "$mount_dir" /bin/bash -s <<-'EOS' locale-gen echo 'LANG=en_US.UTF-8' > /etc/locale.conf + echo '-- Configuring network.' + cat <<-'EOF' > /etc/systemd/network/05-eth0.network + [Match] + Name=eth0 + + [Network] + DHCP=yes + + [DHCPv4] + UseDomains=yes + + [DHCPv6] + UseDomains=yes + EOF + systemctl --quiet enable systemd-networkd.service systemd-resolved.service + echo '-- Configuring journald.' gawk -i assert -i inplace ' /^#ForwardToConsole=/ { $0 = "ForwardToConsole=yes"; ++f } @@ -159,9 +175,6 @@ arch-chroot -- "$mount_dir" /bin/bash -s <<-'EOS' Before=systemd-growfs@-.service EOF - echo '-- Enabling other services.' - systemctl --quiet enable dhclient@eth0.service - echo '-- Configuring initcpio.' gawk -i assert -i inplace ' /^MODULES=/ { $0 = "MODULES=(virtio_pci virtio_scsi sd_mod ext4)"; ++f1 }