Static IP on Kickstart
Shabazian, Chip
chip.shabazian at bankofamerica.com
Tue Jan 18 23:21:03 UTC 2011
You could put the static info on the boot: line, then source it and use it in the %post.
-----Original Message-----
From: kickstart-list-bounces at redhat.com [mailto:kickstart-list-bounces at redhat.com] On Behalf Of Daniel Theisen
Sent: Wednesday, January 12, 2011 5:28 PM
To: kickstart-list at redhat.com
Subject: Static IP on Kickstart
Hello all,
I've been struggling with an issue with my kickstart configuration for a while now.
My current installation procedure:
1. Insert kickstart CD into server and boot
2. Select which kickstart to config from menu
3. Server grabs a DHCP address off a local LAN, gets install data off of a local mirror
4. Coffee while it installs
5. Server reboots
6. Log in and manually run network configuration script (written in %post section) to configure new static IP
What I would like to do is move step 6 to after step 4. I want to be able to run some kind of network installation at the very end of the install process, but before the first reboot.
Our current situation is this. We do server installs on a daily basis, when we kickstart a machine, we plug it into our office VLAN and boot it. It then grabs a DHCP address from our office router and proceeds with a network installation.
Setting a static IP at the beginning of the install is not an option, because we have many different VLAN's for each of our subnets. Some of the VLAN's are offsite and going to our othr site to install a server is not ideal.
Static DHCP is also not an option for multiple reasons. Firtly, we have over 1000 servers already configured with static IP addresses. Although there's no conflict issues, we'd just like to keep IP addresses purely static for consistancy reasons. Secondly, there's the previous VLAN issue. Finally, there's the issue that we have some servers with 20+ IP addresses.
Baasically, it'd just be very nice to be able to configure a static IP address on a server during the actual install process.
Here is my current kickstart script:
auth --useshadow --enablemd5
bootloader --location=mbr
zerombr
clearpart --all --initlabel
text
firewall --enabled --port=22:tcp
firstboot --disable
keyboard us
lang en_US
logging --level=info
url --url=http://mirror.nexcess.net/CentOS/5.5/os/x86_64/
reboot --eject
rootpw --iscrypted xx
selinux --enforcing
skipx
timezone --isUtc America/Detroit
install
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=512 --ondisk=sda
part swap --bytes-per-inode=4096 --fstype="swap" --size=2048 --ondisk=sda
part / --bytes-per-inode=4096 --fstype="ext3" --grow --size=1 --ondisk=sda
part /backup --bytes-per-inode=4096 --fstype="ext3" --grow --size=1 --ondisk=sdb
network --bootproto=dhcp --device=eth0
%packages --nobase
@core
system-config-network-tui
%post
echo "nameserver 4.2.2.1" > /etc/resolv.conf
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
# write netconfig script
cat << EOF > /bin/netconfig
#!/bin/bash
# check if user is root
if [[ \$EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# run system-config-network-tui
/usr/sbin/system-config-network-tui
# set variables
eth0f="/etc/sysconfig/network-scripts/ifcfg-eth0"
eth1f="/etc/sysconfig/network-scripts/ifcfg-eth1"
netcfg="/etc/sysconfig/network"
# turn on eth1 if it has an address, remove gateway.. shouldn't be set here
# anyways
if [ -f "\$eth1f" ]; then
if grep -q "IPADDR" \$eth1f; then
sed -i 's/ONBOOT=no/ONBOOT=yes/' \$eth1f
sed -i '/^GATEWAY/d' \$eth1f
sed -i '/^HOTPLUG/d' \$eth1f
fi
fi
# move gateway from ifcfg-eth0 to /etc/sysconfig/network
if [ -f "\$eth0f" ]; then
e0gw=\$(grep "GATEWAY" \$eth0f)
sed -i '/^GATEWAY/d' \$eth0f
# check to see if the gateway is already set. if it is, delete it first
if ! grep -q "GATEWAY" /etc/sysconfig/network; then
echo \$e0gw >> \$netcfg
else
sed -i '/^GATEWAY/d' \$netcfg
echo \$e0gw >> \$netcfg
fi
fi
EOF
chmod +x /bin/netconfig
At the moment, I have a not-so-elegant script written to the server to be run manually after install. I began using system-config-network-tui vanilla, but realized it had some differences from the network configuration tool in anaconda (net.c?) I tried my best to correct those differences with my netconfig script. I've already tried running system-config-network-tui in the %post section, but it doesn't seem to work.
If anyone has had experience in dealing with a scenario such as this, any help would be greatly appreciated.
Thanks,
Daniel Theisen <dtheisen at nexcess.net>
_______________________________________________
Kickstart-list mailing list
Kickstart-list at redhat.com
https://www.redhat.com/mailman/listinfo/kickstart-list
----------------------------------------------------------------------
This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited.
Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law.
The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses.
References to "Sender" are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this EC may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link:
http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you consent to the foregoing.
More information about the Kickstart-list
mailing list