1 2 3 4 5
mapping <interface_name_glob> script <script_name> map <script_input1> map <script_input2> map ...
example configuration:
1 2 3 4 5
auto eth0 eth1 mapping eth0 eth1 script /path/to/get-mac-address.sh map 11:22:33:44:55:66 lan map AA:BB:CC:DD:EE:FF internet
get-mac-address.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/bin/sh set -e export LANG=C iface="$1" mac=$(/sbin/ifconfig "$iface" | sed -n -e '/^.*HWaddr \([:[:xdigit:]]*\).*/{s//\1/;y/ABCDEF/abcdef/;p;q;}') which="" while read testmac scheme; do if [ "$which" ]; then continue; fi if [ "$mac" = "$(echo "$testmac" | sed -e 'y/ABCDEF/abcdef/')" ]; then which="$scheme"; fi done if [ "$which" ]; then echo $which; exit 0; fi exit 1
The bold sections in the example configuration and the corresponding script show how the "map" inputs are handled.
Reference:
http://addisu.taddese.com/blog/mapping-in-linux-network-interfaces/
https://wiki.debian.org/NetworkConfiguration
No comments:
Post a Comment