It seems not possible on Ubuntu autoinstallations (14.04.3 and 15.04) to configure the right network interface via preseed.
Ubuntu sometimes uses eth0, and sometimes interfaces like p2p1, or p1p3.
I know how these names will be generated. But how can I detect these names during or before the autoinstall? Or how can I automatically rename the p2p1 interface name to the old eth0 name?
To set the static interface settings I use d-i preseed/late_command to overwrite the /etc/network/interfaces file. Right know I assume there is only one interface with the name eth0.
I tried to overwrite/delete the /etc/udev/rules.d/70-persistent-net.rules within the preseed/late_command. But this does not help in any way - it will be ignored.
How can I change the interface name to eth0? Or how can I detect the interface name during the autoinstallation, to write the correct name into the network/interfaces file?
Edit:
The replacement now works great (thanks to "muru"!)
The Interface will initial written from another server and served internal via http wget in the preseed/late_command:
wget http://{InternalServer}/{path}/interfaces -O /etc/network/interfaces;
in the same line i load an additional replaceinterface.sh script with the content:
#!/bin/bash
sDevice=`ip -o link | grep 'link/ether' | grep -oE "^[[:digit:]]:[[:space:]]([[:alnum:]]+)" | cut -d" " -f 2`
sed "s/eth0/$sDevice/g" $1
After loading ,i fire chmod +x, execute it with sh /tmp/replaceinterface.sh < /etc/network/interfaces > /etc/network/interfaces;
But then, after installation is done, the /etc/network/interfaces file is empty (?) ...
If i do the same steps in another console manualy, during installation, i see the correct output / correct modified file
But that seems to be another question for askubuntu.com ..
Edit²:
The Replacement works perfect now - thanks again to "muru" !
#!/bin/bash
sDevice=`ip -o link | grep 'link/ether' | grep -oE "^[[:digit:]]:[[:space:]]([[:alnum:]]+)" | cut -d" " -f 2`
sReplaced=`sed s/eth0/$sDevice/g $1`
echo "$sReplaced" > $1