root@a1000:~# ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
SIOCSIFHWADDR: Device or resource busy - you may need to down the interface
root@a1000:~# ifconfig eth0 down
root@a1000:~# ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
root@a1000:~# ifconfig eth0 up
不过重启又没了
可通过配置文件 /etc/sysconfig/network-scripts/… 进行配置并 service network restart
有的板子没有这些服务或配置文件,可以搞个脚本或命令放到/etc/profile,不过每次起来IP都会变,所以把ip也一起配置了,必须up之后才能配置ip:
root@a1000:~# ifconfig eth0 down
root@a1000:~# ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
root@a1000:~# ifconfig eth0 up
root@a1000:~# ifconfig eth0 xx.xx.10.xx broadcast xx.xx.11.255 netmask 255.255.252.0
root@a1000:~#
#!/bin/sh
mkdir ~/.ssh/
cat > ~/.ssh/authorized_keys << ENDSTRING
ssh-rsa AAAAB3NzaC1yc2E ... 1tXyU+X5pB0= xxx@xxxx.com
ENDSTRING
chmod 0644 ~/.ssh/authorized_keys
cat >> /etc/profile << EOF
#mac
ifconfig eth0 down
ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
ifconfig eth0 up
ifconfig eth0 xx.xx.2.67 broadcast xx.xx.11.255 netmask 255.255.252.0
#habit cmd
alias ll="ls -l"
alias vim="vi"
EOF
source /etc/profile