ifconfig eth0 hw ether

ifconfig hw ether 是一个用于在 Linux 系统中设置或更改网络接口的硬件地址(即 MAC 地址)的命令。具体操作步骤如下:

 

首先,您需要确定要更改 MAC 地址的网络接口名称,通常是 eth0, eth1 等,取决于您的系统配置。

 

接下来,使用 ifconfig 命令配合 hw ether 选项来更改 MAC 地址。例如,如果您想要更改 eth0 接口的 MAC 地址,您可以使用以下命令:

 

sudo ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX

 

 

其中 XX:XX:XX:XX:XX:XX 是您希望设置的新 MAC 地址。

 

更改完成后,您可以使用 ifconfig 命令检查新的 MAC 地址是否已经正确设置:

 

ifconfig eth0

 

 

这将显示 eth0 接口的详细信息,包括新的 MAC 地址。

 

请注意,更改 MAC 地址可能会影响网络连接,因为 MAC 地址是网络上识别设备的唯一标识符。此外,某些网络环境可能限制 MAC 地址的更改,或者要求使用特定的 MAC 地址。

#!/bin/sh /etc/rc.common START=20 STOP=90 SERVICE_DAEMONIZE=1 SERVICE_WRITE_PID=1 DHCPC_FILE="/tmp/firewall/dhcpc_status" DHCPC_FILE_LAN="/tmp/firewall/dhcpc_status_lan" start() { . /usr/share/libubox/jshn.sh echo 2 3 > /proc/gmac_1/driving echo 3 3 > /proc/gmac_1/driving echo 4 3 > /proc/gmac_1/driving echo 5 3 > /proc/gmac_1/driving echo 6 3 > /proc/gmac_1/driving echo 7 3 > /proc/gmac_1/driving echo 2 3 > /proc/gmac_0/driving echo 3 3 > /proc/gmac_0/driving echo 4 3 > /proc/gmac_0/driving echo 5 3 > /proc/gmac_0/driving echo 6 3 > /proc/gmac_0/driving echo 7 3 > /proc/gmac_0/driving init_config service_start /sbin/netifd #added by zb for ppp dial up [ -e /usr/sbin/connModed ] && /usr/sbin/connModed & #begin: added by xiesimin reloadStatistics #end: added by xiesimin #begin: added by xiesimin ubus call tddpServer start #end: added by xiesimin #added by zhoubin smart network #smart_network #smart dhcp detect for dhcpd [ -e /etc/init.d/udhcpd ] && { /etc/init.d/udhcpd reload } #add for multi-network reConfigNetwork } restart() { stop sleep 1 start } shutdown() { #before down all interfaces,should suspend internet,otherwise wan may be up again ubus call internet suspend ifdown -a stop } stop() { local wan_dial_status=4 ubus call internet suspend ubus call internet disconnect #wait for wan down . /lib/netifd/common_api.sh until [ "$wan_dial_status" == "$STATUS_DOWN" ]; do ubus call internet suspend ubus call internet disconnect ifdown -a get_wan_dial_status wan_dial_status done local pid_conn=$(ps | grep -v "grep" | grep connModed) [ -n "$pid_conn" ] && killall connModed service_stop /sbin/netifd rm "$DHCPC_FILE" rm "$DHCPC_FILE_LAN" } reload() { ubus call network reload #begin: added by xiesimin reloadStatistics #end: added by xiesimin } reConfigNetwork() { local proto local type config_load network config_get proto "lan" proto config_get type "wan" type if [ "bond0" == $type ] || [ "bond1" == $type ]; then echo 'bond mode' ifenslave bond0 eth0 eth1 else echo 'multi lan mode, need reConfig.' fi } #begin: added by xiesimin reloadStatistics() { local ifname config_load network # notify wan type to statistic module config_get wan_type "wan" wan_type config_get ifname "wan" ifname [ -e /proc/net/stat_wan_type ] && { echo -n "$wan_type $ifname" > /proc/net/stat_wan_type } config_get wan_type "lan" wan_type config_get ifname "lan" ifname [ -e /proc/net/stat_lan_type ] && { echo -n "$wan_type $ifname" > /proc/net/stat_lan_type } } #end: added by xiesimin bond_config() { local type local mtu config_load network config_get type "wan" type config_get macaddr "wan" macaddr config_get master_networkcard "wan" master_networkcard config_get mtu "wan" mtu if [ "bond1" == $type ]; then echo 'Start bond network config.' ifconfig eth0 down ifconfig eth1 down ifconfig eth0 hw ether $macaddr ifconfig eth1 hw ether $macaddr [ -e /proc/net/bonding ] && { rmmod bonding } insmod bonding mode=1 miimon=200 primary=$master_networkcard ifconfig bond0 mtu $mtu ifconfig eth0 mtu $mtu ifconfig eth1 mtu $mtu ifconfig bond0 up ifconfig eth0 up ifconfig eth1 up ifenslave bond0 eth0 eth1 elif [ "bond0" == $type ]; then echo 'Start bond network config.' ifconfig eth0 down ifconfig eth1 down ifconfig eth0 hw ether $macaddr ifconfig eth1 hw ether $macaddr [ -e /proc/net/bonding ] && { rmmod bonding } insmod bonding mode=0 miimon=200 ifconfig bond0 mtu $mtu ifconfig eth0 mtu $mtu ifconfig eth1 mtu $mtu ifconfig bond0 up ifconfig eth0 up ifconfig eth1 up ifenslave bond0 eth0 eth1 fi } init_config() { revert_config # Config bond network bond_config # sleep 1 ifenslave -d bond0 eth1 ifenslave -d bond0 eth0 } #revert dns when update firmware revert_config() { [ -e /tmp/.update_firmware ] && { config_load network config_get proto "wan" proto if [ "static" != $proto ]; then uci_set network wan netmask '' uci_set network wan ipaddr '' uci_set network wan gateway '' uci_set network wan dns '' uci commit network fi } } export IFNAME export INTERFACE #smart network smart_network() { #waiting for netifd ready #sleep 2 local pre_proto config_load protocol config_get pre_proto "smart_network" proto if [ "$pre_proto" == "dhcp" ]; then . /lib/netifd/common_api.sh get_wan_if IFNAME get_wan_interface_name INTERFACE kill -s USR1 $(cat /var/run/udhcpc-${IFNAME}.pid) #/lib/netifd/dhcp.script leasefail fi config_get pre_proto "smart_network_lan" proto if [ "$pre_proto" == "dhcp" ]; then . /lib/netifd/common_api.sh get_lan_if IFNAME get_lan_interface_name INTERFACE kill -s USR1 $(cat /var/run/udhcpc-${IFNAME}.pid) #/lib/netifd/dhcp.script leasefail fi } mac_to_num() { local mac mac=0x${1//:/} export "$2=$mac" } num_to_mac() { local mac local subNum local num num="$2" local i=0 while [ $i -lt 6 ];do subNum=${num:0:2} num=${num:2} mac="$mac:$subNum" let "i += 1" done mac=${mac:1} eval "export -- \"$1=$mac\"" } acc_mac_addr() { local __out="$1" local __in="$2" mac_to_num "$__in" macNum let "macNum += 1" macNum=$(printf %012X $macNum) num_to_mac "$__out" "$macNum" }
最新发布
11-28
@shift /0 @echo off cd %~dp0 title 修改盒子三码 for /f "tokens=4" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do ( set computer=%%a ) md beifen if not exist "adb\adb.exe" goto err taskkill /IM adb.exe /f taskkill /IM tadb.exe /f taskkill /IM *adb.exe /f taskkill /IM *adb*.exe /f cls adb\adb kill-server color 0B cls echo -------------------------------------------------------------------------------- echo 修改盒子三码 echo. echo 日 期:%DATE% 时间%TIME:~0,8% echo. echo 电脑的IP地址为:%computer% echo. echo 修改三码文件盒子adb必须能开启才能获取信息 echo -------------------------------------------------------------------------------- ECHO "%3" if "%3"=="1" goto 读取三码信息 if "%3"=="2" goto 修改deviceid if "%3"=="3" goto 修改usid if "%3"=="4" goto 修改mac if "%3"=="5" goto 修改mac_wifi if "%3"=="11" goto 修改stbid if "%3"=="6" goto :重启 if "%3"=="7" goto :mac if "%3"=="8" goto :wifi goto end :读取三码信息 echo. adb\adb connect %1:%2 adb\adb root adb\adb connect %1:%2 adb\adb remount adb\adb connect %1:%2 adb\adb devices| find /i "%1:%2" && ( echo.&echo *****机顶盒连接成功***** & echo.) || (goto err2) ping -n 1 127.1 >nul 2>nul adb\adb shell "su -c 'echo mac>/sys/class/unifykeys/name'" adb\adb shell "su -c 'cat /sys/class/unifykeys/read'">1\mac.txt ping -n 1 127.1 >nul 2>nul adb\adb shell "su -c 'echo mac_wifi>/sys/class/unifykeys/name'" adb\adb shell "su -c 'cat /sys/class/unifykeys/read'">1\mac_wifi.txt ping -n 1 127.1 >nul 2>nul adb\adb shell "su -c 'echo deviceid>/sys/class/unifykeys/name'" adb\adb shell "su -c 'cat /sys/class/unifykeys/read'">1\deviceid.txt ping -n 1 127.1 >nul 2>nul adb\adb shell "su -c 'echo usid>/sys/class/unifykeys/name'" adb\adb shell "su -c 'cat /sys/class/unifykeys/read'">1\usid.txt ping -n 1 127.1 >nul 2>nul adb\adb shell "su -c 'echo stbid>/sys/class/unifykeys/name'" adb\adb shell "su -c 'cat /sys/class/unifykeys/read'">1\stbid.txt ping -n 1 127.1 >nul 2>nul exit :修改deviceid echo. adb\adb connect %1:%2 adb\adb root adb\adb connect %1:%2 adb\adb remount adb\adb connect %1:%2 adb\adb devices| find /i "%1:%2" && ( echo.&echo *****机顶盒连接成功***** & echo.) || (goto err2) ping -n 2 127.1 >nul 2>nul adb\adb shell "su -c 'echo deviceid>/sys/class/unifykeys/name'" adb\adb shell "su -c 'echo %4 > /sys/class/unifykeys/write'" adb\adb shell "su -c 'cat /sys/class/unifykeys/read'" ping -n 2 127.1 >nul 2>nul exit :修改usid echo. adb\adb connect %1:%2 adb\adb root adb\adb connect %1:%2 adb\adb remount adb\adb connect %1:%2 adb\adb devices| find /i "%1:%2" && ( echo.&echo *****机顶盒连接成功***** & echo.) || (goto err2) ping -n 2 127.1 >nul 2>nul adb\adb shell "su -c 'echo usid>/sys/class/unifykeys/name'" adb\adb shell "su -c 'echo %4 > /sys/class/unifykeys/write'" adb\adb shell "su -c 'cat /sys/class/unifykeys/read'" ping -n 2 127.1 >nul 2>nul exit :修改mac echo. adb\adb connect %1:%2 adb\adb root adb\adb connect %1:%2 adb\adb remount adb\adb connect %1:%2 adb\adb devices| find /i "%1:%2" && ( echo.&echo *****机顶盒连接成功***** & echo.) || (goto err2) ping -n 2 127.1 >nul 2>nul adb\adb shell "su -c 'echo mac>/sys/class/unifykeys/name'" adb\adb shell "su -c 'echo %4 > /sys/class/unifykeys/write'" adb\adb shell "su -c 'cat /sys/class/unifykeys/read'" ping -n 2 127.1 >nul 2>nul exit :修改mac_wifi echo. adb\adb connect %1:%2 adb\adb root adb\adb connect %1:%2 adb\adb remount adb\adb connect %1:%2 adb\adb devices| find /i "%1:%2" && ( echo.&echo *****机顶盒连接成功***** & echo.) || (goto err2) ping -n 2 127.1 >nul 2>nul adb\adb shell "su -c 'echo mac_wifi>/sys/class/unifykeys/name'" adb\adb shell "su -c 'echo %4 > /sys/class/unifykeys/write'" adb\adb shell "su -c 'cat /sys/class/unifykeys/read'" ping -n 2 127.1 >nul 2>nul exit :修改stbid echo. adb\adb connect %1:%2 adb\adb root adb\adb connect %1:%2 adb\adb remount adb\adb connect %1:%2 adb\adb devices| find /i "%1:%2" && ( echo.&echo *****机顶盒连接成功***** & echo.) || (goto err2) ping -n 2 127.1 >nul 2>nul adb\adb shell "su -c 'echo stbid>/sys/class/unifykeys/name'" adb\adb shell "su -c 'echo %4 > /sys/class/unifykeys/write'" adb\adb shell "su -c 'cat /sys/class/unifykeys/read'" ping -n 2 127.1 >nul 2>nul exit :重启 echo. adb\adb connect %1:%2 adb\adb root adb\adb connect %1:%2 adb\adb remount adb\adb connect %1:%2 adb\adb devices| find /i "%1:%2" && ( echo.&echo *****机顶盒连接成功***** & echo.) || (goto err2) ping -n 2 127.1 >nul 2>nul adb\adb shell reboot exit :mac echo. DIY\adb connect %1:%2 DIY\adb root DIY\adb connect %1:%2 DIY\adb remount DIY\adb connect %1:%2 DIY\adb devices| find /i "%1:%2" && ( echo.&echo *****机顶盒连接成功***** & echo.) || (goto err2) DIY\adb shell mount -o remount,rw /system DIY\adb root DIY\adb shell if [ -e /system/bin/remotecfg.sh ]; then "echo >> /system/bin/remotecfg.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/install-recovery.sh ]; then "echo >> /system/bin/install-recovery.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/preinstall.sh ]; then "echo >> /system/bin/preinstall.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/remotecfg.sh ]; then "echo >> /system/bin/remotecfg.sh busybox ifconfig eth0 down"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/install-recovery.sh ]; then "echo >> /system/bin/install-recovery.sh busybox ifconfig eth0 down"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/preinstall.sh ]; then "echo >> /system/bin/preinstall.sh busybox ifconfig eth0 down"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/remotecfg.sh ]; then "echo >> /system/bin/remotecfg.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/install-recovery.sh ]; then "echo >> /system/bin/install-recovery.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/preinstall.sh ]; then "echo >> /system/bin/preinstall.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/remotecfg.sh ]; then "echo >> /system/bin/remotecfg.sh busybox ifconfig eth0 hw ether %4"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/install-recovery.sh ]; then "echo >> /system/bin/install-recovery.sh busybox ifconfig eth0 hw ether %4"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/preinstall.sh ]; then "echo >> /system/bin/preinstall.sh busybox ifconfig eth0 hw ether %4"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/remotecfg.sh ]; then "echo >> /system/bin/remotecfg.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/install-recovery.sh ]; then "echo >> /system/bin/install-recovery.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/preinstall.sh ]; then "echo >> /system/bin/preinstall.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/remotecfg.sh ]; then "echo >> /system/bin/remotecfg.sh busybox ifconfig eth0 up"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/install-recovery.sh ]; then "echo >> /system/bin/install-recovery.sh busybox ifconfig eth0 up"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/preinstall.sh ]; then "echo >> /system/bin/preinstall.sh busybox ifconfig eth0 up"; else echo "it does not exist"; fi; ECHO 上传完成!! pause&exit :wifi echo. DIY\adb connect %1:%2 DIY\adb root DIY\adb connect %1:%2 DIY\adb remount DIY\adb connect %1:%2 DIY\adb devices| find /i "%1:%2" && ( echo.&echo *****机顶盒连接成功***** & echo.) || (goto err2) DIY\adb shell mount -o remount,rw /system DIY\adb root DIY\adb shell if [ -e /system/bin/remotecfg.sh ]; then "echo >> /system/bin/remotecfg.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/install-recovery.sh ]; then "echo >> /system/bin/install-recovery.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/preinstall.sh ]; then "echo >> /system/bin/preinstall.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/remotecfg.sh ]; then "echo >> /system/bin/remotecfg.sh busybox ifconfig wlan0 down"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/install-recovery.sh ]; then "echo >> /system/bin/install-recovery.sh busybox ifconfig wlan0 down"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/preinstall.sh ]; then "echo >> /system/bin/preinstall.sh busybox ifconfig wlan0 down"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/remotecfg.sh ]; then "echo >> /system/bin/remotecfg.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/install-recovery.sh ]; then "echo >> /system/bin/install-recovery.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/preinstall.sh ]; then "echo >> /system/bin/preinstall.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/remotecfg.sh ]; then "echo >> /system/bin/remotecfg.sh busybox ifconfig wlan0 hw ether %4"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/install-recovery.sh ]; then "echo >> /system/bin/install-recovery.sh busybox ifconfig wlan0 hw ether %4"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/preinstall.sh ]; then "echo >> /system/bin/preinstall.sh busybox ifconfig wlan0 hw ether %4"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/remotecfg.sh ]; then "echo >> /system/bin/remotecfg.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/install-recovery.sh ]; then "echo >> /system/bin/install-recovery.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/preinstall.sh ]; then "echo >> /system/bin/preinstall.sh '\n'"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/remotecfg.sh ]; then "echo >> /system/bin/remotecfg.sh busybox ifconfig wlan0 up"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/install-recovery.sh ]; then "echo >> /system/bin/install-recovery.sh busybox ifconfig wlan0 up"; else echo "it does not exist"; fi; DIY\adb shell if [ -e /system/bin/preinstall.sh ]; then "echo >> /system/bin/preinstall.sh busybox ifconfig wlan0 up"; else echo "it does not exist"; fi; ECHO 上传完成!! pause&exit 给我弄成可以输入ip 链接设备
07-24
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值