This is a quick recipe for enabling DHCP for your Netscaler VPX on KVM:
- Boot the KVM VPX instance per the instructions on the citrix site.
- Create /nsconfig/nsbefore.sh
- Create /nsconfig/nsafter.sh
- Power off your Netscaler VPX and save the disk image as a DHCP-enabled template.
#!/bin/sh
mkdir /var/db # to store lease files
mkdir /var/empty
/sbin/dhclient -l /var/db/dhclient.leases.1 0/1
#!/bin/sh
ADDR=`grep fixed-address /var/db/dhclient.leases.1 | awk '{print $NF}' | sed -e 's/;//' | uniq | tail -1`
SUBNET=`grep subnet-mask /var/db/dhclient.leases.1 | awk '{print $NF}' | sed -e 's/;//' | uniq | tail -1`
GATEWAY=`grep routers /var/db/dhclient.leases.1 | awk '{print $NF}' | sed -e 's/;//' | uniq | tail -1`
grep "$ADDR" /nsconfig/ns.conf
if [ $? != 0 ]; then
nscli -U :nsroot:nsroot "set ns config -IPAddress $ADDR -netmask $SUBNET"
nscli -U :nsroot:nsroot "savec"
sleep 5
yes | nscli -U :nsroot:nsroot "reboot"
fi
grep "$GATEWAY" /nsconfig/ns.conf
if [ $? != 0 ]; then
nscli -U :nsroot:nsroot "add route 0.0.0.0 0.0.0.0 $GATEWAY"
nscli -U :nsroot:nsroot "savec"
fi