Calculate correct netmask
I've added a netmask cidr calculator function from here: http://www.linuxquestions.org/questions/programming-9/bash-cidr-calculator-646701/ Just tested this on Digital Ocean system and it works. The netmask is set correctly after the reboot and networking works.
This commit is contained in:
parent
e09bb60159
commit
e18ed518c7
33
install.sh
33
install.sh
|
@ -267,17 +267,28 @@ postbootstrap_configuration() {
|
||||||
read ignored netmask <&${grepfd}
|
read ignored netmask <&${grepfd}
|
||||||
read ignored gateway <&${grepfd}
|
read ignored gateway <&${grepfd}
|
||||||
exec {grepfd}<&-
|
exec {grepfd}<&-
|
||||||
case ${netmask} in
|
mask2cidr() {
|
||||||
255.255.255.0)
|
nbits=0
|
||||||
prefixlen=24
|
IFS=.
|
||||||
;;
|
for dec in $1 ; do
|
||||||
255.255.240.0)
|
case $dec in
|
||||||
prefixlen=20
|
255) let nbits+=8;;
|
||||||
;;
|
254) let nbits+=7;;
|
||||||
255.255.0.0)
|
252) let nbits+=6;;
|
||||||
prefixlen=16
|
248) let nbits+=5;;
|
||||||
;;
|
240) let nbits+=4;;
|
||||||
esac
|
224) let nbits+=3;;
|
||||||
|
192) let nbits+=2;;
|
||||||
|
128) let nbits+=1;;
|
||||||
|
0);;
|
||||||
|
*) echo "Error: $dec is not recognised"; exit 1
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
echo "$nbits"
|
||||||
|
}
|
||||||
|
|
||||||
|
prefixlen=$(mask2cidr ${netmask})
|
||||||
|
|
||||||
cat > /archroot/etc/systemd/network/internet.network <<EOF
|
cat > /archroot/etc/systemd/network/internet.network <<EOF
|
||||||
[Match]
|
[Match]
|
||||||
Name=eth0
|
Name=eth0
|
||||||
|
|
Loading…
Reference in New Issue