Hi all.
is there an easy way to kickstart a system using DHCP, but then use the obtained settings to define static network configurations on the installed system?
Best Regards Marcus
Am Montag, den 08.03.2010, 09:14 +0100 schrieb Marcus Moeller:
Hi all.
is there an easy way to kickstart a system using DHCP, but then use the obtained settings to define static network configurations on the installed system?
Best Regards Marcus
A simple %post script comes to mind.
financial.com AG
Munich head office/Hauptsitz München: Maria-Probst-Str. 19 | 80939 München | Germany Frankfurt branch office/Niederlassung Frankfurt: Messeturm | Friedrich-Ebert-Anlage 49 | 60327 Frankfurt | Germany Management board/Vorstand: Dr. Steffen Boehnert | Dr. Alexis Eisenhofer | Dr. Yann Samson | Matthias Wiederwach Supervisory board/Aufsichtsrat: Dr. Dr. Ernst zur Linden (chairman/Vorsitzender) Register court/Handelsregister: Munich – HRB 128 972 | Sales tax ID number/St.Nr.: DE205 370 553
2010/3/8 Marcus Moeller mail@marcus-moeller.de:
Hi Christoph,
is there an easy way to kickstart a system using DHCP, but then use the obtained settings to define static network configurations on the installed system?
Best Regards Marcus
A simple %post script comes to mind.
And also to this list ?-)
Okay, got one.
KSDEVICE=`LANG=C /sbin/route -n | awk '/^0.0.0.0/ { print $8 }'` IP=`LANG=C /sbin/ifconfig $KSDEVICE | /bin/awk '/inet/ && !/inet6/ {sub(/addr:/, ""); print $2}'` HOSTNAME=`LANG=C /usr/bin/host $IP | /bin/awk '{sub(/.$/, ""); print $5}'` NETMASK=`LANG=C /sbin/ifconfig $KSDEVICE | /bin/awk '/inet/ && !/inet6/ {sub(/Mask:/, ""); print $4}'` NETWORK=`LANG=C /bin/ipcalc $IP -n $NETMASK | /bin/cut -d= -f2` GATEWAY=`LANG=C echo $NETWORK | awk -F'.' '{print $1"."$2"."$3"."$4+1}'` HWADDR=`LANG=C /sbin/ifconfig $KSDEVICE | /bin/awk '/HWaddr/ { print $5 }'`
cat << EOF > /etc/sysconfig/network NETWORKING=yes HOSTNAME=$HOSTNAME GATEWAY=$GATEWAY EOF
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-$KSDEVICE DEVICE=$KSDEVICE BOOTPROTO=static IPADDR=$IP NETMASK=$NETMASK ONBOOT=yes HWADDR=$HWADDR EOF
Best Regards Marcus