Chroot: Now use a network unit for systemd-networkd
This commit is contained in:
parent
05a3de15ca
commit
521b7ea84a
|
@ -201,28 +201,31 @@ sed -i 's;target;;g' /target/etc/fstab
|
|||
sed -i 's;//;;g' /target/etc/fstab
|
||||
## }}}
|
||||
## Network {{{
|
||||
### Get all informations from current network configuration in rescue mode
|
||||
net_device=$(ip r | grep "^default" | head -1 | cut -d" " -f5)
|
||||
net_address=$(ip r | grep -vE "(^default|metric)" | grep "${net_device}.*src" | head -1 | awk -F" " '{print $NF}')
|
||||
read -r net_mac_address </sys/class/net/"${net_device}"/address
|
||||
net_netmask=$(ipcalc "${net_address}" | awk '/Netmask:/{print $2;}')
|
||||
net_netmask_cidr=$(ipcalc "${net_address}" | awk '/Netmask:/{print $4;}')
|
||||
net_broadcast=$(ip a s dev "${net_device}" | awk '/inet.*brd/{print $4}')
|
||||
net_network=$(ip r | grep -vE "(^default|metric)" | grep "src ${net_address}" | head -1 | cut -d"/" -f1)
|
||||
net_gateway=$(ip r | grep "^default" | head -1 | cut -d" " -f3)
|
||||
|
||||
printf '%b' "auto lo
|
||||
iface lo inet loopback
|
||||
### Create a network unit for systemd-networkd
|
||||
printf '%b' "[Match]
|
||||
MACAddress=${net_mac_address}
|
||||
|
||||
auto ${net_device}
|
||||
iface ${net_device} inet static
|
||||
address ${net_address}
|
||||
netmask ${net_netmask}
|
||||
network ${net_network}
|
||||
broadcast ${net_broadcast}
|
||||
gateway ${net_gateway}
|
||||
# FDN DNS - https://www.fdn.fr/actions/dns/
|
||||
dns-nameserver 80.67.169.12
|
||||
dns-nameserver 80.67.169.40
|
||||
[Network]
|
||||
Description=network interface with default route without dhcp
|
||||
DHCP=no
|
||||
Address=${net_address}/${net_netmask_cidr}
|
||||
Gateway=${net_gateway}
|
||||
IPv6AcceptRA=no
|
||||
DNS=80.67.169.12
|
||||
" > /target/etc/systemd/network/50-default.network
|
||||
|
||||
source-directory /etc/network/interfaces.d" > /target/etc/network/interfaces
|
||||
### Ensure to enable systemd-networkd at startup
|
||||
chroot /target systemctl enable systemd-networkd
|
||||
|
||||
## }}}
|
||||
## Ensure to remount device {{{
|
||||
|
|
Loading…
Reference in New Issue