#!/bin/sh # # PATH=/sbin:/usr/sbin:/bin:/usr/bin run_pre_up() { :; } . /etc/sysconfig/network . /etc/rc.d/init.d/functions . /lib/rc-scripts/functions.network # Will be removed in the future if is_yes "$NETWORKING"; then if [ -z "$IPV4_NETWORKING" ]; then echo "NETWORKING is set to YES, but IPV4_NETWORKING is empty!" echo "Please upgrade your config" echo "Assuming you want IPv4 networking" IPV4_NETWORKING=yes export IPV4_NETWORKING fi fi need_hostname # device name must be ifcfg-somename DEV=$1 [ -z "$DEV" ] && { nls "Usage: %s " "ifup" >&2 exit 1 } if [ $(id -u) != 0 ]; then if [ -x /sbin/usernetctl ]; then exec /sbin/usernetctl $DEV up fi nls "Users cannot control this device." >&2 exit 1 fi if [ -f "/etc/sysconfig/interfaces/ifcfg-$DEV" ]; then CONFIG="/etc/sysconfig/interfaces/ifcfg-$DEV" elif [ -f "/etc/sysconfig/interfaces/$DEV" ]; then CONFIG="/etc/sysconfig/interfaces/$DEV" else CONFIG="$DEV" fi source_config if [ "foo$2" = "fooboot" ] && is_no "${ONBOOT}"; then exit fi if [ "foo$2" = "foohotplug" ] && ! is_yes "${HOTPLUG}"; then exit fi if [ "foo$2" = "foopcmcia-hotplug" ] && ! is_yes "${PCMCIA_HOTPLUG}"; then exit fi IPSETUP=no # set all major variables setup_ip_param SYSCTLDEVICE=$(echo ${DEVICE} | sed 's/\./\//g') # anything you need done first run_pre_up OTHERSCRIPT="/lib/rc-scripts/ifup-${DEVICETYPE}" if [ -x "$OTHERSCRIPT" ]; then if is_yes "$DEFAULTHANDLING"; then HANDLING=1 fi if [ "$HANDLING" = "0" ]; then exec $OTHERSCRIPT $CONFIG $2 elif [ "$HANDLING" = "1" ]; then $OTHERSCRIPT $CONFIG $2 fi fi if [ -n "$MACVLAN_DEV" -a -n "$MACVLAN_MACADDR" ]; then ip link del link ${MACVLAN_DEV} ${DEVICE} type macvlan > /dev/null 2>&1 ip link add link ${MACVLAN_DEV} address ${MACVLAN_MACADDR} name ${DEVICE} type macvlan ${MACVLAN_MODE:+mode $MACVLAN_MODE} fi # is this device available? (this catches PCMCIA devices for us) if ! /sbin/ip link set multicast ${MULTICAST} dev ${DEVICE} > /dev/null 2>&1; then nls "Delaying %s initialization" ${DEVICE} exit 1 fi if [ -n "$MACADDR" ]; then ip link set ${DEVICE} address ${MACADDR} fi ip link set ${DEVICE} multicast ${MULTICAST} ${ARP} down if [ -n "$MTU" ]; then ip link set ${DEVICE} mtu ${MTU} fi if is_yes "${IPV6_NETWORKING}" && is_yes "${IPV6_DISABLE_AUTOCONF}"; then run_cmd "Disabling IPv6 autoconfiguration" sysctl -w net.ipv6.conf.${SYSCTLDEVICE}.autoconf=0 fi if is_wireless_device "${DEVICE}"; then is_yes "${WLAN_UPEARLY}" && ip link set ${DEVICE} up wireless_param ${DEVICE} fi if is_yes "${WLAN_WPA}"; then /usr/sbin/wpa_supplicant -D ${WLAN_WPA_DRIVER:-wext} -c ${WLAN_WPA_CONFIG:-/etc/wpa_supplicant.conf} -i ${DEVICE} ${WLAN_WPA_OPTIONS} -P "/var/run/wpa_supplicant-${DEVICE}.pid" -B [ -z "$WLAN_WPA_WAIT_TIMEOUT" ] && WLAN_WPA_WAIT_TIMEOUT=15 # check_link_down sleeps for 0.5s check_link_down ${DEVICE} $(( $WLAN_WPA_WAIT_TIMEOUT * 2 )) fi if [ -n "$ETHTOOL_OPTS" ] ; then /sbin/ethtool -s $DEVICE $ETHTOOL_OPTS fi if is_yes "$SLAVE" && [ -n "$MASTER" ] ; then # create master if it doesn't exist yet [ ! -d "/sys/class/net/${MASTER}" ] && ip link add "${MASTER}" type bond nls "Enslaving %s to %s" "${DEVICE}" "${MASTER}" ip link set "${DEVICE}" master "${MASTER}" ip link set "${DEVICE}" up exit 0 fi if [ "$HANDLING" = "2" ]; then exit 0 fi if [ -n "$BOOTPROTO" -a "$BOOTPROTO" != "none" -a "$BOOTPROTO" != "static" ]; then if is_yes "$IPV4_NETWORKING"; then set_dhcpclient DHCP_ARGS= if [ -n "$DHCP_CLIENT" ]; then if [ -z "$DHCP_HOSTNAME" ]; then # set DHCP_HOSTNAME only basename DHCP_HOSTNAME=${HOSTNAME%%.*} fi case ${DHCP_CLIENT##*/} in pump) [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-h $DHCP_HOSTNAME" DHCP_ARGS="$DHCP_ARGS -i $DEVICE" ;; dhcpcd) [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-h $DHCP_HOSTNAME" DHCP_ARGS="$DHCP_ARGS $DEVICE" if is_no "$ZEROCONF"; then DHCP_ARGS="$DHCP_ARGS --noipv4ll" fi ;; dhcpxd) [ -n "$DHCP_HOSTNAME" ] && DHCP_ARGS="-H $DHCP_HOSTNAME" DHCP_ARGS="$DHCP_ARGS $DEVICE" ;; dhclient) # Can't specify a host with dhclient ? DHCP_ARGS="$DEVICE -pf /var/run/dhclient.$DEVICE.pid -lf /var/lib/dhclient/dhclient.$DEVICE.leases" if [ -f /etc/dhclient.$DEVICE.conf ] ; then DHCP_ARGS="$DHCP_ARGS -cf /etc/dhclient.$DEVICE.conf" fi ;; avahi-autoipd) DHCP_ARGS="-D $DEVICE" ;; esac fi DHCP_ARGS="$DHCP_OPTIONS $DHCP_ARGS" [ -z "$CHECK_LINK_WAIT_TIMEOUT" ] && CHECK_LINK_WAIT_TIMEOUT=5 if check_link_down ${DEVICE} $(( $CHECK_LINK_WAIT_TIMEOUT * 2 )); then run_cmd "$(nls 'Determining IP information for %s (%s)' "$DEVICE" "${DHCP_CLIENT##*/}")" /bin/false nls '%s: Check cable/radio on-off switch?' "$DEVICE" exit 1 fi if ! run_cmd "$(nls 'Determining IP information for %s (%s)' "$DEVICE" "${DHCP_CLIENT##*/}")" $DHCP_CLIENT $DHCP_ARGS; then exit 1 fi # give time for determining IP information check_device_down && sleep 1 && check_device_down && sleep 3 check_device_down && ip link set ${DEVICE} up fi else # IPv4 in use ? if is_yes "$IPV4_NETWORKING" && [ -n "${IP4ADDR}" ]; then # If broadcast is missing then autocalculate it if ! (echo $IP4ADDROPT | grep -qE "brd|broadcast"); then IP4ADDROPT="brd + ${IP4ADDROPT}" fi if [ -n "${SUBDEVICE}" ]; then ALIAS="label ${SUBDEVICE}" fi if [ -n "$REMIP" ]; then ip addr add ${IP4ADDR} peer ${REMIP} ${ALIAS} dev ${DEVICE} ${IP4ADDROPT} else ip addr add ${IP4ADDR} ${ALIAS} dev ${DEVICE} ${IP4ADDROPT} fi fi # Set device up ip link set ${DEVICE} up # IPv6 in use ? if is_yes "$IPV6_NETWORKING" && [ -n "${IP6ADDR}" ]; then ip addr add ${IP6ADDR} dev ${DEVICE} ${IP6ADDROPT} if [ -n "${IP6ADDRLABEL}" ]; then ip addrlabel add prefix ${IP6ADDR} dev ${DEVICE} label ${IP6ADDRLABEL} fi fi if is_yes "$IPV4_NETWORKING" && [ -n "${IP4ADDR}" -a -x /sbin/arping ]; then # update ARP cache of neighbouring computers /sbin/arping -q -A -c 1 -I ${DEVICE} ${IP4ADDR%/*} { ( sleep 2; /sbin/arping -q -U -c 1 -I ${DEVICE} ${IP4ADDR%/*} ) & } > /dev/null 2>&1 fi # IPv4/6 gateways and default routes setup_ip_gw_ro fi # device have to have ip address set before if is_yes "$PROXYARP"; then run_cmd "$(nls 'Enabling proxy ARP on %s' "${DEVICE}")" sysctl -w net.ipv4.conf.${SYSCTLDEVICE}.proxy_arp=1 fi if [ "$HANDLING" = "3" ]; then exit 0 fi if is_yes "$IPX"; then /lib/rc-scripts/ifup-ipx $DEVICE fi if is_yes "$ENABLE_6TO4"; then # find an usable IPv4 address for this device; might have been obtained by dhcp or ppp for ipv4 in `/sbin/ip addr show dev $DEVICE | awk -F'[ /]+' '/ inet /{print $3}'`; do if [ `ipcalc -n $ipv4/8` != "NETWORK=10.0.0.0" \ -a `ipcalc -n $ipv4/12` != "NETWORK=172.16.0.0" \ -a `ipcalc -n $ipv4/24` != "NETWORK=192.168.0.0" \ -a `ipcalc -n $ipv4/24` != "NETWORK=169.254.0.0" ]; then local_ipv4=$ipv4 local_ipv6=`printf "2002:%02x%02x:%02x%02x::1" $(echo $ipv4 | tr . ' ')` break fi done if [ -n "$local_ipv4" ]; then # we have an usable IPv4 address; set up the tunnel tun6to4=tun6to4_$DEVICE /sbin/ip tunnel add $tun6to4 mode sit ttl 128 remote any local $local_ipv4 /sbin/ip link set dev $tun6to4 up /sbin/ip -6 addr add $local_ipv6/16 dev $tun6to4 /sbin/ip -6 route add 2000::/3 via ::192.88.99.1 dev $tun6to4 metric 1 fi fi if [ "$HANDLING" = "4" ]; then exit 0 fi exec /lib/rc-scripts/ifup-post $CONFIG