anthro398
October 17th, 2005, 03:52 PM
I often have to masquerade on the network for troubleshooting and wrote this simple script this morning to automate the process. It should probably ping the target host prior to trying to assume its MAC address, but I didn't feel like fooling with that as it's only necessary to use this when someone asks me to.
#!/bin/bash
# Switch MAC address to that of machine indicated by passed argument.
# Possible target MAC address
DESK="xx:xx:43:0B:d2:xx" # my desktop
DAVE="00-xx-xx-E7-4D-xx" # Dave's desk
DMZ="00-11-xx-0C-xx-3D" # DMZ
TABLET="00:xx:3F:BD:79:xx" # tablet
LAPTOP="00:xx:43:70:xx:xx" # my laptop
# Check argument passed to script
if [ "$1" == desk ]; then
MAC=$DESK
elif [ "$1" == dave ]; then
MAC=$DAVE
elif [ "$1" == dmz ]; then
MAC=$DMZ
elif [ "$1" == tablet ]; then
MAC=$TABLET
elif [ "$1" == laptop ]; then
MAC=$DESK
else
echo "No target by that name."
MAC="not assigned"
fi
# Execute commands with proper MAC address
ifdown eth0
ifconfig eth0 hw ether $MAC
ifup eth0
ifconfig eth0
#!/bin/bash
# Switch MAC address to that of machine indicated by passed argument.
# Possible target MAC address
DESK="xx:xx:43:0B:d2:xx" # my desktop
DAVE="00-xx-xx-E7-4D-xx" # Dave's desk
DMZ="00-11-xx-0C-xx-3D" # DMZ
TABLET="00:xx:3F:BD:79:xx" # tablet
LAPTOP="00:xx:43:70:xx:xx" # my laptop
# Check argument passed to script
if [ "$1" == desk ]; then
MAC=$DESK
elif [ "$1" == dave ]; then
MAC=$DAVE
elif [ "$1" == dmz ]; then
MAC=$DMZ
elif [ "$1" == tablet ]; then
MAC=$TABLET
elif [ "$1" == laptop ]; then
MAC=$DESK
else
echo "No target by that name."
MAC="not assigned"
fi
# Execute commands with proper MAC address
ifdown eth0
ifconfig eth0 hw ether $MAC
ifup eth0
ifconfig eth0