Linux, 工作, 生活, 家人

Ubuntu

Ubuntu 18.04 Change Mac Address on QEMU via Netplan

This is a quick note about how to modify mac address for qemu image with ubuntu 18.04 cloud image.

but I have not found a working way only change mac address in system

Add mac parameter to qemu command

in qemu command line, add mac= parameter to netdev option , ex:

-device virtio-net-device,netdev=net2,mac=52:54:00:56:12:34 \

Modify netplan

edit file /etc/netplan/50-cloud-init.yaml, and add section match, ex

network:
     version: 2
     ethernets:
         eth0:
             dhcp4: true
             match:
                 macaddress: 52:54:00:56:12:34
             set-name: eth0

now, you can shutdown qemu system and restart .

* Notice: if used ubuntu cloud image, please assign mac address before init it.
suppose that cloud image might save mac address some where .

發佈留言