Index: src/etc/defaults/rc.conf =================================================================== RCS file: /home/ncvs/src/etc/defaults/rc.conf,v retrieving revision 1.205 diff -u -r1.205 rc.conf --- src/etc/defaults/rc.conf 10 Apr 2004 22:13:27 -0000 1.205 +++ src/etc/defaults/rc.conf 20 May 2004 17:43:07 -0000 @@ -120,6 +120,7 @@ # NOTE: this violates the TCP specification icmp_drop_redirect="NO" # Set to YES to ignore ICMP REDIRECT packets icmp_log_redirect="NO" # Set to YES to log ICMP REDIRECT packets +network_interfaces_rename="NO" # Network interface name pairs (or "NO") network_interfaces="auto" # List of network interfaces (or "auto"). cloned_interfaces="" # List of cloned network interfaces to create. #cloned_interfaces="gif0 gif1 gif2 gif3" # Pre-cloning GENERIC config. Index: src/etc/network.subr =================================================================== RCS file: /home/ncvs/src/etc/network.subr,v retrieving revision 1.153 diff -u -r1.153 network.subr --- src/etc/network.subr 11 Aug 2003 20:32:00 -0000 1.153 +++ src/etc/network.subr 21 May 2004 06:40:15 -0000 @@ -623,3 +623,35 @@ esac done } + +# Rename interfaces if the network_interfaces_rename variable is set +# to 'old new' pair(s), e.g. 'sis0 ethlocal xl0 ethext'. +rename_ifaces() +{ + echo -n 'Renaming interfaces: ' + case "${network_interfaces_rename}" in + [Nn][Oo] | '') + echo 'none' + ;; + + *) + if [ "$1" = 'stop' ]; then + set ${network_interfaces_rename} + _v='' + while [ -n "$1" ]; do + _v="$1 ${_v}" + shift + done + set ${_v} + else + set ${network_interfaces_rename} + fi + while [ -n "$2" ]; do + echo -n "$1 -> $2 " + ifconfig "$1" name "$2" + shift 2 + done + echo 'done' + ;; + esac +} Index: src/etc/rc.d/netif =================================================================== RCS file: /home/ncvs/src/etc/rc.d/netif,v retrieving revision 1.7 diff -u -r1.7 netif --- src/etc/rc.d/netif 28 Apr 2004 13:20:15 -0000 1.7 +++ src/etc/rc.d/netif 21 May 2004 06:42:25 -0000 @@ -47,6 +47,9 @@ # We're operating as a general network start routine. # + # Rename interfaces if requested + rename_ifaces start + # Create cloned interfaces clone_up @@ -70,6 +73,9 @@ # Deconfigure the interface(s) network_common ifn_stop echo '.' + + # Rename interfaces back if needed + rename_ifaces stop } # network_common routine verbose Index: src/share/man/man5/rc.conf.5 =================================================================== RCS file: /home/ncvs/src/share/man/man5/rc.conf.5,v retrieving revision 1.216 diff -u -r1.216 rc.conf.5 --- src/share/man/man5/rc.conf.5 28 Apr 2004 23:16:06 -0000 1.216 +++ src/share/man/man5/rc.conf.5 20 May 2004 17:54:22 -0000 @@ -860,6 +860,31 @@ Refer to .Xr ip 4 for more information. +.It Va network_interfaces_rename +.Pq Vt str +Set to a list of pairs of network interface names to rename on boot. +For example, if you want the +.Li sis0 +interface to be actually seen as +.Li ethlocal +and the +.Li xl0 +interface to be seen as +.Li ethext , +this could be set to +.Dq Li "sis0 ethlocal xl0 ethext" . +.Pp +Additionally, +.Xr ifconfig 8 +may allow specifying interfaces by link-level address by prefixing the +address with +.Dq hw- , +e.g. +.Dq Li hw-00:03:0d:08:dc:a7 . +In this case, you can set the +.Va network_interfaces_rename +variable to +.Dq Li "hw-00:03:0d:08:dc:a7 ethlocal" . .It Va network_interfaces .Pq Vt str Set to the list of network interfaces to configure on this host.