Configure eth0 within images

This commit is contained in:
Bob Mottram 2018-03-10 12:45:40 +00:00
parent 9fe1f91722
commit 9c60ac9110
1 changed files with 13 additions and 9 deletions

View File

@ -203,16 +203,17 @@ configure_networking() {
return return
fi fi
if [[ "$GENERIC_IMAGE" == "no" ]]; then { echo '# This file describes the network interfaces available on your system';
echo '# This file describes the network interfaces available on your system' > "$rootdir/etc/network/interfaces" echo '# and how to activate them. For more information, see interfaces(5).';
echo '# and how to activate them. For more information, see interfaces(5).' >> "$rootdir/etc/network/interfaces" echo 'source /etc/network/interfaces.d/*'; } > "$rootdir/etc/network/interfaces"
echo 'source /etc/network/interfaces.d/*' >> "$rootdir/etc/network/interfaces"
echo "auto eth0 if [[ "$GENERIC_IMAGE" == "no" ]]; then
iface eth0 inet static
address $BOX_IP_ADDRESS { echo 'auto eth0';
netmask 255.255.255.0 echo 'iface eth0 inet static';
gateway $ROUTER_IP_ADDRESS" > "$rootdir/etc/network/interfaces.d/static" echo "address $BOX_IP_ADDRESS";
echo 'netmask 255.255.255.0';
echo "gateway $ROUTER_IP_ADDRESS"; } > "$rootdir/etc/network/interfaces.d/static"
hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f ) hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]} a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
@ -221,6 +222,9 @@ iface eth0 inet static
d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]} d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]} e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
echo "hwaddress ether de:$a:$b:$c:$d:$e" > "$rootdir/etc/network/interfaces.d/macaddress" echo "hwaddress ether de:$a:$b:$c:$d:$e" > "$rootdir/etc/network/interfaces.d/macaddress"
else
{ echo 'auto eth0';
echo 'iface eth0 inet dhcp'; } > "$rootdir/etc/network/interfaces.d/dynamic"
fi fi
# configure DNS # configure DNS