1

How can I add a virtual NIC with a specific MAC address on a cloud server?

I recently acquired a cloud based service with Centos 7 in it.

I have an application that runs on a specific MAC address only.

How can I clone this MAC address or add another virtual NIC with this MAC address?

I tried adding a virtual NIC like eth0:1 , it got added fine, but the MAC address is the same as eth0, however I need a different MAC address.

  • Interface aliases do not have their own MAC address. – Rui F Ribeiro Sep 23 '16 at 12:20
1

If you don't need to route any traffic over it, you could use the dummy interface

eg before:

$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 52:54:00:0c:d8:88 brd ff:ff:ff:ff:ff:ff

Now we use the dummy module, and get a new interface:

$ sudo modprobe dummy
$ sudo ip link set dummy0 address 10:20:30:40:50:60
$ ip link show dummy0                            
3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT 
    link/ether 10:20:30:40:50:60 brd ff:ff:ff:ff:ff:ff

This has created an interface called dummy0 with the MAC address we requested.

Another option could be to create a tap device:

$ sudo ip tuntap add dev tap0 mode tap
$ sudo ip link set tap0 address 10:20:30:40:50:61
$ ip link show tap0
4: tap0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 500
    link/ether 10:20:30:40:50:61 brd ff:ff:ff:ff:ff:ff

With tap devices you can call it any name you like, even cheat and call it eth1.

  • Thx Mr, @Stephen Harris Lately I contacted the Hosting service provider support and they told me that they have some restriction and the mac cannot be cloned or changed on any interface, Strange! Any way later I moved to Digital Ocean hosting provider and selected Ubuntu 12.4 as OS, and I was successfully able to create a dummy interface by using ip link add link eth0 address 11:22:33:44:55:66 eth0.1 type macvlan ifconfig eth0.1 up ifconfig eth0.1 10.0.0.2 Thanks for your advise, I will try it again when get a chance. – Syed Jahanzaib Sep 25 '16 at 10:50

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.