Как указать qemu использовать определенный MAC-адрес на сетевом мосту?

Единственное, что не так с вашей конфигурацией, это адрес обновления сервера. Должно быть:

# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf

use=web
web=checkip.dyndns.com
web-skip='Current IP Address: '

protocol=dyndns2
server=dynupdate.no-ip.com
login=myusername
password='mypass'
myhost.noip.me

Вы можете протестировать конфигурацию, выполнив:

sudo ddclient -verbose -foreground

И вы должны увидеть, как часть маршрутизатора (извлекает IP-адреса с помощью «веб-провайдера» ), затем выполняется аутентификация без -IP и IP-адрес обновляется:

ONNECT:  checkip.dyndns.com
CONNECTED:  using HTTP
SENDING:  GET / HTTP/1.0
SENDING:   Host: checkip.dyndns.com
SENDING:   User-Agent: ddclient/3.8.3
SENDING:   Connection: close
SENDING:   
RECEIVE:  HTTP/1.1 200 OK
RECEIVE:  Content-Type: text/html
RECEIVE:  Server: DynDNS-CheckIP/1.0.1
RECEIVE:  Connection: close
RECEIVE:  Cache-Control: no-cache
RECEIVE:  Pragma: no-cache
RECEIVE:  Content-Length: 106
RECEIVE:  
RECEIVE:  <html><head><title>Current IP Check</title></head><body>Current IP Address: X.X.X.X</body></html>
INFO:     setting IP address to X.X.X.X for myhost.noip.me
UPDATE:   updating myhost.noip.me
CONNECT:  dynupdate.no-ip.com
CONNECTED:  using HTTP
SENDING:  GET /nic/update?system=dyndns&hostname=myhost.noip.me&myip=X.X.X.X HTTP/1.0
SENDING:   Host: dynupdate.no-ip.com
SENDING:   Authorization: Basic bHBlbmFwQGdtYWlsLmNvbToyNjg3OGxhcA==
SENDING:   User-Agent: ddclient/3.8.3
SENDING:   Connection: close
SENDING:   
RECEIVE:  HTTP/1.0 200 OK
RECEIVE:  server: envoy
RECEIVE:  content-type: text/plain; charset=UTF-8
RECEIVE:  cache-control: no-cache
RECEIVE:  date: Fri, 26 Jul 2019 18:48:25 GMT
RECEIVE:  connection: close
RECEIVE:  
RECEIVE:  good X.X.X.X
SUCCESS:  updating myhost.noip.me: good: IP address set to X.X.X.X
0
21.08.2021, 20:46
1 ответ

Наконец-то я понял!

Вот что virt-installбудет делать по умолчанию:

sudo virt-install --network network=default,model=e1000,mac=00:11:22:33:44:55

И эквивалентом qemu-system-x86_64будет:

INTERFACE_NAME="$(sudo cat /var/lib/libvirt/dnsmasq/default.conf | grep "^interface=" | cut -d'=' -f2-)"
sudo qemu-system-x86_64 -net nic,model=e1000,macaddr=00:11:22:33:44:55 -net bridge,br=${INTERFACE_NAME}

Я бы посоветовал сначала убедиться, что сеть defaultактивна:

if ! sudo virsh net-list | grep default | grep --quiet active; then
    sudo virsh net-start default
fi

Примечание. :Вся сеть по умолчанию предоставляется пакетомlibvirt-daemon-config-network(по крайней мере в Fedora ).

Из справочной страницы qemu:

   -net nic[,netdev=nd][,macaddr=mac][,model=type] [,name=name][,addr=addr][,vectors=v]
          Legacy  option to configure or create an on-board (or machine default) Network Interface Card(NIC) and connect it either to the emulated hub with ID 0 (i.e. the default hub), or to the netdev nd.  If model is omitted,
          then the default NIC model associated with the machine type is used. Note that the default NIC model may change in future QEMU releases, so it is highly recommended to always specify a model. Optionally, the  MAC  ad‐
          dress  can  be changed to mac, the device address set to addr (PCI cards only), and a name can be assigned for use in monitor commands. Optionally, for PCI cards, you can specify the number v of MSI-X vectors that the
          card should have; this option currently only affects virtio cards; set v = 0 to disable MSI-X. If no -net option is specified, a single NIC is created. QEMU can emulate several different models of network  card.   Use
          -net nic,model=help for a list of available devices for your target.

   -net user|tap|bridge|socket|l2tpv3|vde[,...][,name=name]
          Configure a host network backend (with the options corresponding to the same -netdev option) and connect it to the emulated hub 0 (the default hub). Use name to specify the name of the hub port.

На виртуальной -странице руководства по установке:

NETWORKING OPTIONS
   -w, --network
       Syntax: -w, --network OPTIONS

       Connect the guest to the host network. Examples for specifying the network type:

       bridge=BRIDGE
              Connect to a bridge device in the host called BRIDGE. Use this option if the host has static networking config & the guest requires full outbound and inbound connectivity  to/from the LAN. Also use this if live migra‐
              tion will be used with this guest.

       network=NAME
              Connect  to  a virtual network in the host called NAME. Virtual networks can be listed, created, deleted using the virsh command line tool. In an unmodified install of libvirt there is usually a virtual network with a
              name of default. Use a virtual network if the host has dynamic networking (eg NetworkManager), or using wireless. The guest will be NATed to the LAN by whichever connection is active.

       type=direct,source=IFACE[,source.mode=MODE]
              Direct connect to host interface IFACE using macvtap.

       user   Connect to the LAN using SLIRP. Only use this if running a QEMU guest as an unprivileged user. This provides a very limited form of NAT.

       none   Tell virt-install not to add any default network interface.

       If --network is omitted a single NIC will be created in the guest. If there is a bridge device in the host with a physical interface attached, that will be used for connectivity. Failing that, the virtual network called  de‐
       fault will be used. This option can be specified multiple times to setup more than one NIC.

       Some example suboptions:

       model.type or model
              Network device model as seen by the guest. Value can be any nic model supported by the hypervisor, e.g.: 'e1000', 'rtl8139', 'virtio',...

       mac.address or mac
              Fixed  MAC address for the guest; If this parameter is omitted, or the value RANDOM is specified a suitable address will be randomly generated. For Xen virtual machines it is required that the first 3 pairs in the MAC
              address be the sequence '00:16:3e', while for QEMU or KVM virtual machines it must be '52:54:00'.

       filterref.filter
              Controlling firewall and network filtering in libvirt. Value can be any nwfilter defined by the virsh 'nwfilter' subcommands. Available filters can be listed by running 'virsh  nwfilter-list',  e.g.:  'clean-traffic',
              'no-mac-spoofing',...

       virtualport.* options
              Configure the device virtual port profile. This is used for 802.Qbg, 802.Qbh, midonet, and openvswitch config.

              Use --network=? to see a list of all available sub options.  Complete details at https://libvirt.org/formatdomain.html#elementsNICS

              This option deprecates -m/--mac, -b/--bridge, and --nonetworks
2
22.08.2021, 00:25

Теги

Похожие вопросы