2020-08-22 OpenWRT 脚本修改网卡MAC

脚本修改网卡MAC

#!/bin/sh

LAN_DEVICE="eth0"
URL="http://127.0.0.1:80/file.txt"

NEW_MAC=$(curl -s ${URL} |cut -c 4- -)
if test -z ${NEW_MAC} ; then \
  exit
fi

ip link set dev ${LAN_DEVICE} down
sleep 1
ip link set dev ${LAN_DEVICE} address $NEW_MAC
if test $? -ne 0 ; then \
  echo "Error: failed to change MAC on device ${LAN_DEVICE}"
else
  echo "Note: device ${LAN_DEVICE} is set to new MAC ${NEW_MAC}"
fi
sleep 1
ip link set dev ${LAN_DEVICE} up

你可能感兴趣的:(linux,python,shell,mac,centos)