add mtu and macaddr to ip=
parent
8a5456e872
commit
990e945ffd
|
@ -260,16 +260,19 @@ Network
|
||||||
|
|
||||||
ibft::: iBFT autoconfiguration
|
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.
|
This parameter can be specified multiple times.
|
||||||
+
|
+
|
||||||
dhcp|on|any|dhcp6::: get ip from dhcp server on a specific interface
|
dhcp|on|any|dhcp6::: get ip from dhcp server on a specific interface
|
||||||
auto6::: do IPv6 autoconfiguration
|
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
|
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
|
in brackets (e.g. [2001:DB8::1]). This parameter can be specified multiple
|
||||||
times.
|
times.
|
||||||
|
+
|
||||||
|
<macaddr>::: optionally set <macaddr> on the <interface>
|
||||||
|
|
||||||
**ifname=**_<interface>_:_<MAC>_::
|
**ifname=**_<interface>_:_<MAC>_::
|
||||||
Assign network device name <interface> (ie eth0) to the NIC with MAC <MAC>.
|
Assign network device name <interface> (ie eth0) to the NIC with MAC <MAC>.
|
||||||
|
|
|
@ -10,9 +10,7 @@
|
||||||
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
|
||||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||||
export PS4="ifup.$1.$$ + "
|
type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
|
||||||
exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe
|
|
||||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
|
||||||
|
|
||||||
# Huh? No $1?
|
# Huh? No $1?
|
||||||
[ -z "$1" ] && exit 1
|
[ -z "$1" ] && exit 1
|
||||||
|
@ -107,6 +105,8 @@ do_static() {
|
||||||
{
|
{
|
||||||
echo ip link set $netif up
|
echo ip link set $netif up
|
||||||
echo wait_for_if_up $netif
|
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
|
# do not flush addr for ipv6
|
||||||
strstr $ip '*:*:*' || \
|
strstr $ip '*:*:*' || \
|
||||||
echo ip addr flush dev $netif
|
echo ip addr flush dev $netif
|
||||||
|
@ -219,12 +219,12 @@ for p in $(getargs ip=); do
|
||||||
ip_to_var $p
|
ip_to_var $p
|
||||||
# skip ibft
|
# skip ibft
|
||||||
[ "$autoconf" = "ibft" ] && continue
|
[ "$autoconf" = "ibft" ] && continue
|
||||||
|
|
||||||
# If this option isn't directed at our interface, skip it
|
# If this option isn't directed at our interface, skip it
|
||||||
[ -n "$dev" ] && [ "$dev" != "$netif" ] && continue
|
[ -n "$dev" ] && [ "$dev" != "$netif" ] && continue
|
||||||
|
|
||||||
# Store config for later use
|
# 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'"'
|
eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
|
||||||
done > /tmp/net.$netif.override
|
done > /tmp/net.$netif.override
|
||||||
|
|
||||||
|
|
|
@ -225,3 +225,30 @@ parse_iscsi_root()
|
||||||
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 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
|
||||||
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
# Format:
|
# Format:
|
||||||
# ip=[dhcp|on|any]
|
# 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
|
# When supplying more than only ip= line, <interface> is mandatory and
|
||||||
# bootdev= must contain the name of the primary interface to use for
|
# bootdev= must contain the name of the primary interface to use for
|
||||||
|
|
|
@ -38,6 +38,8 @@ for netif in $IFACES ; do
|
||||||
echo "ONBOOT=yes"
|
echo "ONBOOT=yes"
|
||||||
echo "NETBOOT=yes"
|
echo "NETBOOT=yes"
|
||||||
echo "UUID=$uuid"
|
echo "UUID=$uuid"
|
||||||
|
[ -n "$macaddr" ] && echo "MACADDR=$macaddr"
|
||||||
|
[ -n "$mtu" ] && echo "MTU=$mtu"
|
||||||
if [ -f /tmp/net.$netif.lease ]; then
|
if [ -f /tmp/net.$netif.lease ]; then
|
||||||
strstr "$ip" '*:*:*' &&
|
strstr "$ip" '*:*:*' &&
|
||||||
echo "DHCPV6C=yes"
|
echo "DHCPV6C=yes"
|
||||||
|
@ -60,6 +62,7 @@ for netif in $IFACES ; do
|
||||||
echo "HWADDR=$(cat /sys/class/net/$netif/address)"
|
echo "HWADDR=$(cat /sys/class/net/$netif/address)"
|
||||||
echo "TYPE=Ethernet"
|
echo "TYPE=Ethernet"
|
||||||
echo "NAME=\"Boot Disk\""
|
echo "NAME=\"Boot Disk\""
|
||||||
|
[ -n "$mtu" ] && echo "MTU=$mtu"
|
||||||
} >> /tmp/ifcfg/ifcfg-$netif
|
} >> /tmp/ifcfg/ifcfg-$netif
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -436,32 +436,6 @@ nfsroot_to_var() {
|
||||||
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
|
# Create udev rule match for a device with its device name, or the udev property
|
||||||
# ID_FS_UUID or ID_FS_LABEL
|
# ID_FS_UUID or ID_FS_LABEL
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue