#!/bin/sh ######################################################################## # Begin $network_devices/services/ipv4-static # # Description : IPV4 Static Boot Script # # Authors : Nathan Coulson - nathan@linuxfromscratch.org # Kevin P. Fleming - kpfleming@linuxfromscratch.org # Michael Tremer - mitch@ipfire.org # Maniacikarus - Maniacikarus@ipfire.org # # Version : 00.00 # # Notes : # ######################################################################## . /etc/sysconfig/rc . ${rc_functions} eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) if [ -z "${BROADCAST}" ]; then boot_mesg "BROADCAST variable missing from input, cannot continue." ${FAILURE} echo_failure exit 1 fi if [ -n "${ADDRESS}" -a -n "${NETMASK}" ]; then PREFIX=`whatmask ${NETMASK} | grep -e ^CIDR | awk -F': ' '{ print $2 }' | cut -c 2-` args="${args} ${ADDRESS}/${PREFIX} broadcast ${BROADCAST}" else boot_mesg "ADDRESS and/or NETMASK variable missing from input, cannot continue." ${FAILURE} echo_failure exit 1 fi case "${2}" in up) boot_mesg "Adding IPv4 address ${ADDRESS} to the ${1} interface..." ip addr add ${args} dev ${1} evaluate_retval if [ -n "${GATEWAY}" ]; then if ip route | grep -q default; then boot_mesg "Gateway already setup; skipping." ${WARNING} echo_warning elif [ "${CONFIG_TYPE}" == "0" ] || [ "${CONFIG_TYPE}" == "" ] && [ "${GATEWAY}" != "" ]; then boot_mesg "Setting up default gateway for green only..." ip route add default via ${GATEWAY} dev ${1} evaluate_retval if [ "${DNS1}" != "" ];then boot_mesg "Registering DNS Server for green only..." echo "nameserver $DNS1" > /etc/resolv.conf fi if [ "${DNS2}" != "" ];then echo "nameserver $DNS2" >> /etc/resolv.conf fi else boot_mesg "Setting up default gateway..." echo $DEFAULT_GATEWAY > /var/ipfire/red/remote-ipaddress ip route add default via ${GATEWAY} dev ${1} evaluate_retval boot_mesg "Registering DNS server..." echo $DNS1 > /var/ipfire/red/dns1 echo $DNS2 > /var/ipfire/red/dns2 echo $ADDRESS > /var/ipfire/red/local-ipaddress evaluate_retval fi fi ;; down) if [ -n "${GATEWAY}" ]; then boot_mesg "Removing default gateway..." ip route del default evaluate_retval fi boot_mesg "Removing IPv4 address ${ADDRESS} from the ${1} interface..." ip addr del ${args} dev ${1} evaluate_retval ;; *) echo "Usage: ${0} [interface] {up|down}" exit 1 ;; esac # End $network_devices/services/ipv4-static