Browse Source

add mtu and macaddr to ip=

master
Harald Hoyer 13 years ago
parent
commit
990e945ffd
  1. 7
      dracut.cmdline.7.asc
  2. 10
      modules.d/40network/ifup.sh
  3. 27
      modules.d/40network/net-lib.sh
  4. 4
      modules.d/40network/parse-ip-opts.sh
  5. 3
      modules.d/45ifcfg/write-ifcfg.sh
  6. 26
      modules.d/99base/dracut-lib.sh

7
dracut.cmdline.7.asc

@ -260,16 +260,19 @@ Network @@ -260,16 +260,19 @@ Network

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>.

10
modules.d/40network/ifup.sh

@ -10,9 +10,7 @@ @@ -10,9 +10,7 @@
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
@ -107,6 +105,8 @@ do_static() { @@ -107,6 +105,8 @@ do_static() {
{
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
@ -219,12 +219,12 @@ for p in $(getargs ip=); do @@ -219,12 +219,12 @@ for p in $(getargs ip=); do
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


27
modules.d/40network/net-lib.sh

@ -225,3 +225,30 @@ parse_iscsi_root() @@ -225,3 +225,30 @@ parse_iscsi_root()
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
}

4
modules.d/40network/parse-ip-opts.sh

@ -5,9 +5,9 @@ @@ -5,9 +5,9 @@
# 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

3
modules.d/45ifcfg/write-ifcfg.sh

@ -38,6 +38,8 @@ for netif in $IFACES ; do @@ -38,6 +38,8 @@ for netif in $IFACES ; do
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"
@ -60,6 +62,7 @@ for netif in $IFACES ; do @@ -60,6 +62,7 @@ for netif in $IFACES ; do
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


26
modules.d/99base/dracut-lib.sh

@ -436,32 +436,6 @@ nfsroot_to_var() { @@ -436,32 +436,6 @@ nfsroot_to_var() {
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
#

Loading…
Cancel
Save