You can now spoof the source address for arping as the third parameter in gateways_eth0 if you have arping2 installed, #180888.
This commit is contained in:
parent
1152e2677c
commit
6ffd3b5289
@ -1,6 +1,11 @@
|
|||||||
# ChangeLog for Gentoo System Intialization ("rc") scripts
|
# ChangeLog for Gentoo System Intialization ("rc") scripts
|
||||||
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2
|
# Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2
|
||||||
|
|
||||||
|
30 Oct 2007; Roy Marples <uberlord@gentoo.org>:
|
||||||
|
|
||||||
|
You can now spoof the source address for arping as the third parameter
|
||||||
|
in gateways_eth0 if you have arping2 installed, #180888.
|
||||||
|
|
||||||
29 Oct 2007; Roy Marples <uberlord@gentoo.org>:
|
29 Oct 2007; Roy Marples <uberlord@gentoo.org>:
|
||||||
|
|
||||||
rc --override foo will override the runlevel to load after boot
|
rc --override foo will override the runlevel to load after boot
|
||||||
|
@ -528,6 +528,13 @@
|
|||||||
#routes_010000000001_334455DDEEFF="default via 10.0.0.1"
|
#routes_010000000001_334455DDEEFF="default via 10.0.0.1"
|
||||||
#dns_servers_010000000001_334455DDEEFF="10.0.0.1"
|
#dns_servers_010000000001_334455DDEEFF="10.0.0.1"
|
||||||
|
|
||||||
|
# If you need to spoof the source address, you can add that as third parameter
|
||||||
|
# like so
|
||||||
|
#gateways_eth0="192.168.0.1,00:11:22:AA:BB:CC,192.168.0.50"
|
||||||
|
#or
|
||||||
|
#gateways_eth0="192.168.0.1,,192.168.0.50"
|
||||||
|
# This requires arping to be installed though
|
||||||
|
|
||||||
# If we don't find any gateways (or there are none configured) then we try and
|
# If we don't find any gateways (or there are none configured) then we try and
|
||||||
# use APIPA to find a free address in the range 169.254.0.0-169.254.255.255
|
# use APIPA to find a free address in the range 169.254.0.0-169.254.255.255
|
||||||
# by arping a random address in that range on the interface. If no reply is
|
# by arping a random address in that range on the interface. If no reply is
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
arping_depend() {
|
arping_depend() {
|
||||||
program /sbin/arping
|
program /sbin/arping /usr/sbin/arping2
|
||||||
before interface
|
before interface
|
||||||
}
|
}
|
||||||
|
|
||||||
arping_address() {
|
arping_address() {
|
||||||
local ip=${1%%/*} mac="$2" foundmac= i= w= opts=
|
local ip=${1%%/*} mac="$2" spoof="$3" foundmac= i= w= opts=
|
||||||
|
|
||||||
# We only handle IPv4 addresses
|
# We only handle IPv4 addresses
|
||||||
case "${ip}" in
|
case "${ip}" in
|
||||||
@ -23,10 +23,20 @@ arping_address() {
|
|||||||
eval w=\$arping_wait_${IFVAR}
|
eval w=\$arping_wait_${IFVAR}
|
||||||
[ -z "${w}" ] && w=${arping_wait:-5}
|
[ -z "${w}" ] && w=${arping_wait:-5}
|
||||||
|
|
||||||
[ -z "$(_get_inet_address)" ] && opts="${opts} -D"
|
if type arping2 >/dev/null 2>&1; then
|
||||||
|
[ -z "$(_get_inet_address)" ] && opts="${opts} -0"
|
||||||
|
[ -n "${spoof}" ] && opts="${opts} -S ${spoof}"
|
||||||
|
while [ ${w} -gt 0 -a -z "${foundmac}" ]; do
|
||||||
|
foundmac="$(arping2 ${opts} -r -c 1 -0 -i "${IFACE}" "${ip}" 2>/dev/null | \
|
||||||
|
sed -e 'y/abcdef/ABCDEF/')"
|
||||||
|
w=$((${w} - 1))
|
||||||
|
done
|
||||||
|
else
|
||||||
|
[ -z "$(_get_inet_address)" ] && opts="${opts} -D"
|
||||||
|
|
||||||
foundmac="$(arping -w "${w}" ${opts} -f -I "${IFACE}" "${ip}" 2>/dev/null | \
|
foundmac="$(arping -w "${w}" ${opts} -f -I "${IFACE}" "${ip}" 2>/dev/null | \
|
||||||
sed -n -e 'y/abcdef/ABCDEF/' -e 's/.*\[\([^]]*\)\].*/\1/p')"
|
sed -n -e 'y/abcdef/ABCDEF/' -e 's/.*\[\([^]]*\)\].*/\1/p')"
|
||||||
|
fi
|
||||||
[ -z "${foundmac}" ] && return 1
|
[ -z "${foundmac}" ] && return 1
|
||||||
|
|
||||||
if [ -n "${mac}" ] ; then
|
if [ -n "${mac}" ] ; then
|
||||||
@ -41,7 +51,7 @@ arping_address() {
|
|||||||
|
|
||||||
_arping_in_config() {
|
_arping_in_config() {
|
||||||
_get_array "config_${IFVAR}" | while read i; do
|
_get_array "config_${IFVAR}" | while read i; do
|
||||||
[ "${i}" = "arping" ] && return 0
|
[ "${i}" = "arping" ] && return 1
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@ -51,7 +61,7 @@ arping_start() {
|
|||||||
einfo "Pinging gateways on ${IFACE} for configuration"
|
einfo "Pinging gateways on ${IFACE} for configuration"
|
||||||
|
|
||||||
eval gateways=\$gateways_${IFVAR}
|
eval gateways=\$gateways_${IFVAR}
|
||||||
if [ -n "${gateways}" ] ; then
|
if [ -z "${gateways}" ] ; then
|
||||||
eerror "No gateways have been defined (gateways_${IFVAR}=\"...\")"
|
eerror "No gateways have been defined (gateways_${IFVAR}=\"...\")"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -61,7 +71,7 @@ arping_start() {
|
|||||||
for x in ${gateways}; do
|
for x in ${gateways}; do
|
||||||
local IFS=,
|
local IFS=,
|
||||||
set -- ${x}
|
set -- ${x}
|
||||||
local ip=$1 mac=$2 extra=
|
local ip=$1 mac=$2 spoof=$3 extra=
|
||||||
unset IFS
|
unset IFS
|
||||||
|
|
||||||
if [ -n "${mac}" ] ; then
|
if [ -n "${mac}" ] ; then
|
||||||
@ -70,9 +80,8 @@ arping_start() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
vebegin "${ip} ${extra}"
|
vebegin "${ip} ${extra}"
|
||||||
if arping_address "${ip}" "${mac}" ; then
|
if arping_address "${ip}" "${mac}" "${spoof}" ; then
|
||||||
local OIFS=$IFS SIFS=${IFS-y}
|
local IFS=.
|
||||||
IFS=.
|
|
||||||
for i in ${ip} ; do
|
for i in ${ip} ; do
|
||||||
if [ "${#i}" = "2" ] ; then
|
if [ "${#i}" = "2" ] ; then
|
||||||
conf="${conf}0${i}"
|
conf="${conf}0${i}"
|
||||||
@ -82,28 +91,28 @@ arping_start() {
|
|||||||
conf="${conf}${i}"
|
conf="${conf}${i}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ "${SIFS}" = "y" ] ; then
|
unset IFS
|
||||||
IFS=$OFIS
|
|
||||||
else
|
|
||||||
unset IFS
|
|
||||||
fi
|
|
||||||
[ -n "${mac}" ] && conf="${conf}_$(echo "${mac}" | sed -e 's/://g')"
|
[ -n "${mac}" ] && conf="${conf}_$(echo "${mac}" | sed -e 's/://g')"
|
||||||
|
|
||||||
veend 0
|
eend 0
|
||||||
eoutdent
|
eoutdent
|
||||||
veinfo "Configuring ${IFACE} for ${ip} ${extra}"
|
veinfo "Configuring ${IFACE} for ${ip} ${extra}"
|
||||||
_configure_variables "${conf}"
|
_configure_variables ${conf}
|
||||||
|
|
||||||
# Call the system module as we've aleady passed it by ....
|
# Call the system module as we've aleady passed it by ....
|
||||||
# And it *has* to be pre_start for other things to work correctly
|
# And it *has* to be pre_start for other things to work correctly
|
||||||
system_pre_start
|
system_pre_start
|
||||||
|
|
||||||
# Ensure that we have a valid config - ie arping is no longer there
|
# Ensure that we have a valid config - ie arping is no longer there
|
||||||
if _arping_in_config; then
|
local IFS="$__IFS"
|
||||||
veend 1 "No config found for ${ip} (config_${conf}=\"...\")"
|
for i in $(_get_array "config_${IFVAR}"); do
|
||||||
continue 2
|
if [ "${i}" = "arping" ]; then
|
||||||
fi
|
eend 1 "No config found for ${ip} (config_${conf}=\"...\")"
|
||||||
|
continue 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
unset IFS
|
||||||
|
|
||||||
_load_config
|
_load_config
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user