linux 配置mac地址

4 篇文章 0 订阅
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
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值