From 38d24a3c402275ad61e68e0bb0a230de513dc35a Mon Sep 17 00:00:00 2001 From: James Rayner Date: Thu, 26 Feb 2009 21:29:36 +1100 Subject: [PATCH] Migrate from ifconfig -> iproute2 --- network | 22 ++++++++-------------- rc.conf | 6 +++--- rc.sysinit | 3 ++- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/network b/network index 26cc9db..a35517d 100755 --- a/network +++ b/network @@ -28,7 +28,8 @@ ifup() /bin/rm -f /var/run/dhcpcd-${1}.cache >/dev/null 2>&1 /sbin/dhcpcd $DHCPCD_ARGS ${1} else - /sbin/ifconfig $ifcfg + /usr/sbin/ip addr add $ifcfg + /usr/sbin/ip link set ${1} up fi return $? } @@ -63,7 +64,8 @@ ifdown() fi fi # Always bring the interface itself down - /sbin/ifconfig ${1} down >/dev/null 2>&1 + /usr/sbin/ip addr flush ${1} >/dev/null 2>&1 + /usr/sbin/ip link set ${1} down >/dev/null 2>&1 return $? } @@ -87,11 +89,7 @@ rtup() return 1 fi eval routecfg="\$${1}" - if grep -q :: <<< $routecfg; then - /sbin/route -A inet6 add $routecfg - else - /sbin/route add $routecfg - fi + /usr/sbin/ip route add $routecfg return $? } @@ -102,11 +100,7 @@ rtdown() return 1 fi eval routecfg="\$${1}" - if grep -q :: <<< $routecfg; then - /sbin/route -A inet6 del $routecfg - else - /sbin/route del $routecfg - fi + /usr/sbin/ip route del $routecfg return $? } @@ -138,8 +132,8 @@ bridge_up() for br in ${BRIDGE_INTERFACES[@]}; do if [ "$br" = "${br#!}" ]; then # if the bridge already exists, remove it - if [ "$(/sbin/ifconfig $br 2>/dev/null)" ]; then - /sbin/ifconfig $br down + if [ "$(/usr/sbin/ip link show $br 2>/dev/null)" ]; then + /usr/sbin/ip link set $br down /usr/sbin/brctl delbr $br fi /usr/sbin/brctl addbr $br diff --git a/rc.conf b/rc.conf index 48455f8..7c28bc6 100644 --- a/rc.conf +++ b/rc.conf @@ -49,7 +49,7 @@ USELVM="no" # HOSTNAME="myhost" -# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces. +# Use 'ip link show' or 'ls /sys/class/net/' to see all available interfaces. # # Interfaces to start at boot-up (in this order) # Declare each interface then list in INTERFACES @@ -59,14 +59,14 @@ HOSTNAME="myhost" # DHCP: Set your interface to "dhcp" (eth0="dhcp") # Wireless: See network profiles below # -eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255" +eth0="192.168.1.2/24 brd + dev eth0" INTERFACES=(eth0) # Routes to start at boot-up (in this order) # Declare each route then list in ROUTES # - prefix an entry in ROUTES with a ! to disable it # -gateway="default gw 192.168.0.1" +gateway="default via 192.168.1.1" ROUTES=(!gateway) # Enable these network profiles at boot-up. These are only useful diff --git a/rc.sysinit b/rc.sysinit index d4d3249..bd1777a 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -126,7 +126,8 @@ fi # bring up the loopback interface if [ -d /sys/class/net/lo ]; then stat_busy "Bringing up loopback interface" - /sbin/ifconfig lo 127.0.0.1 up + /usr/sbin/ip addr add 127.0.0.1/8 brd + dev lo + /usr/sbin/ip link set lo up if [ $? -ne 0 ]; then stat_fail else -- 1.6.1