friedgold
Group: Members
Posts: 122
Joined: Mar. 2005 |
|
Posted: May 05 2005,13:14 |
|
I thought it would be handy to set your network settings at boot via a cheatcode. This is mainly for people with no dhcp server. To do this I edited /etc/init.d/knoppix-autoconifg as follows
find the section starting
Code Sample | if checkbootparam "nodhcp"; then ... |
and change it to
Code Sample | if checkbootparam "nodhcp"; then echo " ${BLUE}Skipping DHCP broadcast/network detection as requested on boot commandline.${NORMAL}" else NETDEVICES="$(awk -F: '/eth.:|tr.:/{print $1}' /proc/net/dev 2>/dev/null)" for DEVICE in $NETDEVICES do echo " ${GREEN}Network device ${MAGENTA}$DEVICE${GREEN} detected${NORMAL}" NETSETTINGS="$(getbootparam $DEVICE 2>/dev/null)" if [ -n "$NETSETTINGS" ]; then IP="$(echo "$NETSETTINGS" | cut -d , -f 1)" NM="$(echo "$NETSETTINGS" | cut -d , -f 2)" DG="$(echo "$NETSETTINGS" | cut -d , -f 3)" NS="$(echo "$NETSETTINGS" | cut -d , -f 4)" NETSETTINGS_ERR="" for i in $IP $NM $DG $NS; do [ -n "$i" ] && [ -z "$(echo "$i" | awk '/^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$/')" ] && NETSETTINGS_ERR="yes" done if [ -n "$NETSETTINGS_ERR" ]; then echo " ${BLUE}Invalid network settings, skipping network configuration.${NORMAL}" else ifconfig $DEVICE $IP netmask ${NM:-255.255.255.0} >/dev/null 2>&1 sleep 1 [ -n "$DG" ] && route add default gw $DG >/dev/null 2>&1 [ -n "$NS" ] && echo "nameserver $NS">/etc/resolv.conf echo " ${GREEN}Using Static IP:${YELLOW} $IP${NORMAL}" fi else trap 2 3 11 pump -i $DEVICE >/dev/null 2>&1 & trap "" 2 3 11 sleep 1 echo " ${BLUE}(Backgrounding)${NORMAL}" fi done fi |
I then remastered as normal
You can then use the cheatcode eth0=ip,nm,dg,dns where ip is your IP address, nm your netmask, dg your default gateway and dns your dns server. Only the ip address is required, the rest is optional (i.e. you can use eth0=192.168.1.100 to get you network up, although without a gateway/dns server you won't be able to get on the internet). In theory if you have more than one network card you can use eth0=... eth1=... etc to set each one up.
|