1

All the examples I see on internet for changing the mac address of an interface in linux, first makes the interface down and then update the mac address and finally bring the interface up. But, I can see that the mac can be changed without bringing the interface down. Is it the right way to do without bringing the interface down. Can it cause some issue?

6
  • How exactly do you see that MAC address can be changed without bringing the I down ? Please explain it in your question. Mar 26, 2018 at 14:32
  • @C0deDaedalus In all the examples, I see something like this: "ifconfig eth0 down" then "ifconfig eth0 hw ether 00:80:48:BA:d1:30" and finally "ifconfig eth0 up". But if I directly give "ifconfig eth0 hw ether 00:80:48:BA:d1:30" without any ifconfig down and up, it works. So, I was concerned if I can use this command directly, or I need to do ifconfig down and up for the interface. Mar 26, 2018 at 14:52
  • @user8070445 What are you actually trying to accomplish that involves changing the MAC address?
    – Alex
    Mar 26, 2018 at 15:14
  • @Alex its a virtual dpdk KNI interface, I need to set the mac of this KNI interface same as that of the port which is selected as a tunnel port. Since the tunnel port can be changed dynamically, hence I need to change the mac of this KNI interface accordingly. Mar 26, 2018 at 15:17
  • @user8070445 , I tried that Command and it says SIOCSIFHWADDR: Device or resource busy - you may need to down the interface Mar 26, 2018 at 17:20

1 Answer 1

0

Are you sure you need to change the MAC address? The documentation for what you're trying to do states:

The MAC address can be the real NIC MAC address or random.

7
  • For the solution which I am working on requires it to be same mac as of the actual nic port which is selected as the tunnel port. Mar 26, 2018 at 15:26
  • @user8070445 That sounds like it wouldn't be portable, so it doesn't make a ton of sense. Are you sure? I suggest scrubbing the documentation a bit more, as it seems to disagree with you.
    – Alex
    Mar 26, 2018 at 15:27
  • 2
    How does this answer the question(s)? Mar 26, 2018 at 15:28
  • @KamilMaciorowski The only thing better than being told how to do something that sounds like a hack is learning that you don't actually need to do it after all; the documentation suggests this is indeed the case, hence my suggestion.
    – Alex
    Mar 26, 2018 at 15:30
  • @Alex Suppose I have an ISC DHCP server running in Linux space listening on the dpdk virtual KNI interface, for assigning IP address to clients behind tunnel. Hence, I need same mac address on my tunnel port and KNI interface for ARP resolution between client behind the tunnel and dhcp server listening on the KNI interface. Mar 26, 2018 at 15:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .