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
fi
if [[ "$GENERIC_IMAGE" == "no" ]]; then
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).' >> "$rootdir/etc/network/interfaces"
echo 'source /etc/network/interfaces.d/*' >> "$rootdir/etc/network/interfaces"
{ echo '# This file describes the network interfaces available on your system';
echo '# and how to activate them. For more information, see interfaces(5).';
echo 'source /etc/network/interfaces.d/*'; } > "$rootdir/etc/network/interfaces"
echo "auto eth0
iface eth0 inet static
address $BOX_IP_ADDRESS
netmask 255.255.255.0
gateway $ROUTER_IP_ADDRESS" > "$rootdir/etc/network/interfaces.d/static"
if [[ "$GENERIC_IMAGE" == "no" ]]; then
{ echo 'auto eth0';
echo 'iface eth0 inet 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 )
a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
@ -221,6 +222,9 @@ iface eth0 inet static
d=${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"
else
{ echo 'auto eth0';
echo 'iface eth0 inet dhcp'; } > "$rootdir/etc/network/interfaces.d/dynamic"
fi
# configure DNS