红联Linux门户
Linux帮助

Fedora21及22永久修改MAC地址

发布时间:2015-07-19 10:30:06来源:blog.csdn.net/yunyuan_zhang作者:yunyuan_zhang

由于fedora21版本的使用的有线设备名字改为enp4s0,所以不能够按照一般的eth0的linux系统去修改MAC地址,可以按照如下步骤修改MAC地址:


1,输入:ifconfig 命令首先查看mac地址是多少,看看有线设备是不是enpts0:

enp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500 
inet 58.198.102.27  netmask 255.255.255.0  broadcast 58.198.102.255 
inet6 2001:da8:8006:407:ca1f:66ff:fe49:941b  prefixlen 64  scopeid 0x0<global> 
inet6 fe80::ca1f:66ff:fe49:941b  prefixlen 64  scopeid 0x20<link> 
ether c8:1f:66:49:94:1b  txqueuelen 1000  (Ethernet) 
RX packets 50120  bytes 3152813 (3.0 MiB) 
RX errors 0  dropped 0  overruns 0  frame 0 
TX packets 2117  bytes 181616 (177.3 KiB) 
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 
     
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536 
inet 127.0.0.1  netmask 255.0.0.0 
inet6 ::1  prefixlen 128  scopeid 0x10<host> 
loop  txqueuelen 0  (Local Loopback) 
RX packets 176  bytes 15828 (15.4 KiB) 
RX errors 0  dropped 0  overruns 0  frame 0 
TX packets 176  bytes 15828 (15.4 KiB) 
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 


2,输入:sudo ifconfig enp4s0 down


3:输入:cd /etc/sysconfig/network-scripts/  找到ifcfg-enp4s0文件

ifcfg-enp4s0文件为:

MACADDR=C8:1F:66:49:94:1B 
TYPE="Ethernet" 
BOOTPROTO="dhcp" 
DEFROUTE="yes" 
IPV4_FAILURE_FATAL="no" 
IPV6INIT="yes" 
IPV6_AUTOCONF="yes" 
IPV6_DEFROUTE="yes" 
IPV6_FAILURE_FATAL="no" 
NAME="enp4s0" 
UUID="5981df8c-4764-4338-bf48-32d23c017de1" 
ONBOOT="yes" 
PEERDNS=yes 
PEERROUTES=yes 
IPV6_PEERDNS=yes 
IPV6_PEERROUTES=yes 
~       
~     

修改其中的"HWADDR=xx:xx:xx:xx:xx:xx"为"MACADDR=xx:xx:xx:xx:xx:xx",即可


4,输入:sudo ifconfig enp4s0 up 启动enp4s0


5,输入:service network start ,如果出现network.service failed情况,请往下如下操作:


6:输入:systemctl status network.service

network.service - LSB: Bring up/down networking 
Loaded: loaded (/etc/rc.d/init.d/network) 
Active: failed (Result: exit-code) since Thu 2015-07-16 09:10:18 EDT; 58s ago 
Docs: man:systemd-sysv-generator(8)Process: 6974 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE) 


7,输入:systemctl enable NetworkManager-wait-online.service


8,systemctl start network.service


9:输入:systemctl status network.service

network.service - LSB: Bring up/down networking 
Loaded: loaded (/etc/rc.d/init.d/network) 
Active: activating (<span style="color:#FF6666;">start</span>) since Thu 2015-07-16 09:13:54 EDT; 27s ago 
Docs: man:systemd-sysv-generator(8) 
Control: 8564 (network) 
CGroup: /system.slice/network.service 
├─8564 /bin/bash /etc/rc.d/init.d/network start 
├─8925 /bin/bash ./ifup Wired_connection_3 boot 
└─8956 nmcli con up uuid 4f530eb2-a6aa-4e6f-828f-1d5cc32371ba 


现在重启,永久修改MAC地址。


Snow Leopard、Ubuntu、Windows下修改网卡MAC地址:http://www.linuxdiyf.com/linux/9107.html

Linux下获取eth网卡MAC地址的代码 :http://www.linuxdiyf.com/linux/9004.html

Linux下修改错误的MAC地址[图文]:http://www.linuxdiyf.com/linux/8421.html

Linux下修改MAC地址的工具macchanger的使用:http://www.linuxdiyf.com/linux/9724.html

Ubuntu更改mac地址:http://www.linuxdiyf.com/linux/1011.html