ibft::: iBFT autoconfiguration
-**ip=**_<interface>_:_{dhcp|on|any|dhcp6|auto6}_::
+**ip=**_<interface>_:_{dhcp|on|any|dhcp6|auto6}_[:[_<mtu>_][:_<macaddr>_]]::
This parameter can be specified multiple times.
+
dhcp|on|any|dhcp6::: get ip from dhcp server on a specific interface
auto6::: do IPv6 autoconfiguration
+<macaddr>::: optionally set <macaddr> on the <interface>
-**ip=**_<client-IP>_:_<server-IP>_:_<gateway-IP>_:_<netmask>_:_<client_hostname>_:_<interface>_:_{none|off}_::
+**ip=**_<client-IP>_:_<server-IP>_:_<gateway-IP>_:_<netmask>_:_<client_hostname>_:_<interface>_:_{none|off|dhcp|on|any|dhcp6|auto6|ibft}_[:[_<mtu>_][:_<macaddr>_]]::
explicit network configuration. If you want do define a IPv6 address, put it
in brackets (e.g. [2001:DB8::1]). This parameter can be specified multiple
times.
++
+<macaddr>::: optionally set <macaddr> on the <interface>
**ifname=**_<interface>_:_<MAC>_::
Assign network device name <interface> (ie eth0) to the NIC with MAC <MAC>.
PATH=/usr/sbin:/usr/bin:/sbin:/bin
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-export PS4="ifup.$1.$$ + "
-exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
# Huh? No $1?
[ -z "$1" ] && exit 1
{
echo ip link set $netif up
echo wait_for_if_up $netif
+ [ -n "$macaddr" ] && echo ip link set address $macaddr
+ [ -n "$mtu" ] && echo ip link set mtu $mtu
# do not flush addr for ipv6
strstr $ip '*:*:*' || \
echo ip addr flush dev $netif
ip_to_var $p
# skip ibft
[ "$autoconf" = "ibft" ] && continue
-
+
# If this option isn't directed at our interface, skip it
[ -n "$dev" ] && [ "$dev" != "$netif" ] && continue
# Store config for later use
- for i in ip srv gw mask hostname; do
+ for i in ip srv gw mask hostname macaddr; do
eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
done > /tmp/net.$netif.override
fi
}
+ip_to_var() {
+ local v=${1}:
+ local i
+ set --
+ while [ -n "$v" ]; do
+ if [ "${v#\[*:*:*\]:}" != "$v" ]; then
+ # handle IPv6 address
+ i="${v%%\]:*}"
+ i="${i##\[}"
+ set -- "$@" "$i"
+ v=${v#\[$i\]:}
+ else
+ set -- "$@" "${v%%:*}"
+ v=${v#*:}
+ fi
+ done
+
+ unset ip srv gw mask hostname dev autoconf macaddr mtu
+ case $# in
+ 0) autoconf="error" ;;
+ 1) autoconf=$1 ;;
+ 2) dev=$1; autoconf=$2 ;;
+ 3) dev=$1; autoconf=$2; mtu=$3 ;;
+ 4) dev=$1; autoconf=$2; mtu=$3; macaddr=$4 ;;
+ *) ip=$1; srv=$2; gw=$3; mask=$4; hostname=$5; dev=$6; autoconf=$7; mtu=$8; macaddr=$9 ;;
+ esac
+}
# Format:
# ip=[dhcp|on|any]
#
-# ip=<interface>:[dhcp|on|any]
+# ip=<interface>:[dhcp|on|any][:[<mtu>][:<macaddr>]]
#
-# ip=<client-IP-number>:<server-IP-number>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:[dhcp|on|any|none|off]
+# ip=<client-IP-number>:<server-IP-number>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:{dhcp|on|any|none|off}[:[<mtu>][:<macaddr>]]
#
# When supplying more than only ip= line, <interface> is mandatory and
# bootdev= must contain the name of the primary interface to use for
echo "ONBOOT=yes"
echo "NETBOOT=yes"
echo "UUID=$uuid"
+ [ -n "$macaddr" ] && echo "MACADDR=$macaddr"
+ [ -n "$mtu" ] && echo "MTU=$mtu"
if [ -f /tmp/net.$netif.lease ]; then
strstr "$ip" '*:*:*' &&
echo "DHCPV6C=yes"
echo "HWADDR=$(cat /sys/class/net/$netif/address)"
echo "TYPE=Ethernet"
echo "NAME=\"Boot Disk\""
+ [ -n "$mtu" ] && echo "MTU=$mtu"
} >> /tmp/ifcfg/ifcfg-$netif
fi
fi
}
-ip_to_var() {
- local v=${1}:
- local i
- set --
- while [ -n "$v" ]; do
- if [ "${v#\[*:*:*\]:}" != "$v" ]; then
- # handle IPv6 address
- i="${v%%\]:*}"
- i="${i##\[}"
- set -- "$@" "$i"
- v=${v#\[$i\]:}
- else
- set -- "$@" "${v%%:*}"
- v=${v#*:}
- fi
- done
-
- unset ip srv gw mask hostname dev autoconf
- case $# in
- 0) autoconf="error" ;;
- 1) autoconf=$1 ;;
- 2) dev=$1; autoconf=$2 ;;
- *) ip=$1; srv=$2; gw=$3; mask=$4; hostname=$5; dev=$6; autoconf=$7 ;;
- esac
-}
-
# Create udev rule match for a device with its device name, or the udev property
# ID_FS_UUID or ID_FS_LABEL
#