Use "ip" command and identify using MAC addresses (RPM)

pull/4/head
Javi Fontan 10 years ago
parent 1c33cbaa10
commit 3c27734e77

@ -72,10 +72,6 @@ get_interfaces() {
$IFCMD | grep ^eth | sed 's/ *Link encap:Ethernet.*HWaddr /-/g' $IFCMD | grep ^eth | sed 's/ *Link encap:Ethernet.*HWaddr /-/g'
} }
get_dev() {
echo $1 | cut -d'-' -f 1
}
get_mac() { get_mac() {
echo $1 | cut -d'-' -f 2 echo $1 | cut -d'-' -f 2
} }
@ -127,14 +123,33 @@ EOT
echo "" echo ""
} }
get_interface_mac()
{
ip link show | awk '/^[0-9]+: [[:alnum:]]+:/ { device=$2; gsub(/:/, "",device)} /link\/ether/ { print device " " $2 }'
}
get_context_interfaces()
{
env | grep -E "^ETH[0-9]+_MAC=" | sed 's/_.*$//' | sort
}
get_dev()
{
list="$1"
mac="$2"
echo "$list" | grep "$mac" | cut -d' ' -f1 | tail -n1
}
gen_network_configuration() gen_network_configuration()
{ {
IFACES=`get_interfaces` INTERFACE_MAC=$(get_interface_mac)
CONTEXT_INTERFACES=$(get_context_interfaces)
for i in $IFACES; do for interface in $CONTEXT_INTERFACES; do
MAC=`get_mac $i` UPCASE_DEV=$interface
DEV=`get_dev $i` MAC=$(get_iface_var "MAC")
UPCASE_DEV=`upcase $DEV` DEV=$(get_dev "$INTERFACE_MAC" "$MAC")
IP=$(get_ip) IP=$(get_ip)
NETWORK=$(get_network) NETWORK=$(get_network)

Loading…
Cancel
Save