0

I'm running a CentOS 5.4 box for which I need to spoof a MAC address in order to make a certain software work (nothing illegal going on, before you ask).

Problem: Whenever I try to change the MAC, I no longer can connect to the network, not even the gateway.

I've used:

ip link set eth0 address <mac>

My ifcfg-eth0 file:

# Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller
DEVICE=eth0
BOOTPROTO=none
IPADDR=192.168.0.34
NETMASK=255.255.255.0
NETWORK=192.168.0.0
GATEWAY=192.168.0.36
ONBOOT=yes
NM_CONTROLLED=yes
TYPE=Ethernet
DNS1=<hidden>
DNS2=<hidden>
DOMAIN=<hidden>

Whenever I restore the original MAC address, I regain connectivity.

Perhaps it's related to the NIC brand/model? I'm at a loss, and would like to rule out software-related issues before buying a new NIC.

Any help is appreciated. Thanks in advance!

11
  • 2
    How long did you wait? Did you try clearing arp on the routers/switches in your broadcast domain? Did you try to use arping to send gratuitous arp once you had your new MAC? What type of switch/router are you using?
    – Aaron
    Jan 30, 2017 at 15:10
  • Spoofing an existing MAC address will really mess up a network. If you are trying to make up your own MAC address, did you make sure the U/L and I/G bits are set correctly?
    – Ron Maupin
    Jan 30, 2017 at 15:18
  • +1 to what Aaron said, use arping to advertise your new MAC address.
    – Mugurel
    Jan 30, 2017 at 15:29
  • @Mugurel how would I go about advertising that? Jan 30, 2017 at 16:25
  • @RonMaupin I'm actually cloning the MAC from a production environment box, so I guess we can assume the bits are fine, no? Jan 30, 2017 at 16:27

2 Answers 2

0

Are you connected via ethernet cable to a cisco switch ? if yes, check the Switchport security settings if they are enabled and if they are allowing only 1 MAC address (the original one).

4
  • Yes, it's a Cisco. I'll give it a try Jan 30, 2017 at 16:25
  • Update: no effect Jan 30, 2017 at 20:10
  • what cisco unit ? can you provide more details ?
    – Ottootto
    Jan 31, 2017 at 7:51
  • It's a SG300-52. So far I fiddled with port security - increasing maximum to 5, and also cleared the ARP cache, but to no avail. Jan 31, 2017 at 15:49
0

unfortunately I do not have sufficient reputation to comment... So I'm posting this as an answer. Whilst I have no experience of changing the MAC address on CentOS 5, I have done it on CentOS 6, which had a similar issue, no network after changing the MAC address.

I discovered that CentOS 6 persists the current MAC in a net rules file and if the hardware disagrees with the settings you get failure. So in order to fix simply delete the file and reboot, as if the file is missing CentOS 6 will re-create it.

The command used to fix CentOS 6 is

sudo rm /etc/udev/rules.d/70-persistent-net.rules
1
  • I don't have such file, and rebooting does not recreate it. Perhaps it's different on 5.4. Jan 30, 2017 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.