Skip to main content
added 27 characters in body
Source Link
Marc.2377
  • 1.2k
  • 1
  • 18
  • 44

I have a script that should create a macvlan bridge in the host when it starts up. The host is an up-to-date Arch Linux. This is intended to allow host and guest to share the same network *and talk to each other*. I found instructions given at:

I have a script that should create a macvlan bridge in the host when it starts up. The host is an up-to-date Arch Linux. This is intended to allow host and guest to share the same network. I found instructions given at:

I have a script that should create a macvlan bridge in the host when it starts up. The host is an up-to-date Arch Linux. This is intended to allow host and guest to share the same network *and talk to each other*. I found instructions given at:

deleted 20 characters in body
Source Link
Marc.2377
  • 1.2k
  • 1
  • 18
  • 44

Help sharing network connection between KVM guest and Script to create macvlan bridge on the host doesn't work unless it's run twice

Following instructions given at (https://www.furorteutonicus.eu/2013/08/04/enabling-host-guest-networking-with-kvm-macvlan-and-macvtap/) in order to be able to reach my VM network from the host, I createdhave a script that should create a macvlan bridge in the host when it starts up. The host is an up-to-date Arch Linux. This is intended to allow host and guest to share the same network. I found instructions given at:

Thenhttps://www.furorteutonicus.eu/2013/08/04/enabling-host-guest-networking-with-kvm-macvlan-and-macvtap

(Regarding the execution at startup, I followed instructions fromalso consulted (How to write startup script for Systemd?) and (https://stackoverflow.com/questions/21830670/systemd-start-service-after-specific-service) to run the script on host startup.

The problem, however, is that the script doesn't do what it's supposed to, when it'sis not effective at first runtry. When I runIt creates the macvlan device and the routing table, but doesn't make it possible for the host to ping the guest and vice-versa.

But when executed a second time, it works - that is, despite an error message it workswhich reads "create_macvlan_bridge.sh[4489]: RTNETLINK answers: File exists".
This error message I'm referring to is: Host can now ping guest as expected.

create_macvlan_bridge.sh[4489]: RTNETLINK answers: File exists

I reinforce thatIt's supposed to work at first try, despite this messagethough, everything works as expected. But I'd like it to work correctly the first timeand I can't figure out why it's not. Can anyone help?

The issue is present whether I'm invoking[Update] I noticed the script directly or viaresult of systemctl startip create_macvlan_bridgea.

[Edit] When shows a second create_macvlan_bridge.serviceinet is enabled, after booting, I get this outputentry for systemctl statusmacvlan0@enp10s0 after the second execution:

create_macvlan_bridge.service - Create_macvlan_bridge
Loadedmacvlan0@enp10s0: loaded (/etc/systemd/system/create_macvlan_bridge.service;<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc enabled; vendor preset: disabled)noqueue state UP group default qlen 1000
Active     link/ether da: inactive (dead) since <datetime> <timezone>; 15s ago
Processa2: 492 ExecStart=/usr/local/bin/create_macvlan_bridge.sh (code=exited, status=0/SUCCESS)
Main PID21: 492 (code=exited, status=0/SUCCESS)

<datetime> <hostname> systemd[1]d1: Starting Create_macvlan_bridge...
<datetime> <hostname> create_macvlan_bridge.sh[492]95: ping24 brd ff: kernel.orgff: Name or service not known
<datetime> <hostname> create_macvlan_bridge.sh[492]ff: /usr/local/bin/create_macvlan_bridge.shff: Cannot ping kernel.org, waiting another 5 secsff:ff
    inet 192.168.1.3/24 scope global macvlan0
<datetime> <hostname> systemd[1]: Started Create_macvlan_bridge.         valid_lft forever preferred_lft forever
    inet 192.168.1.22/24 brd 192.168.1.255 scope global secondary macvlan0
        valid_lft forever preferred_lft forever

Notice how this second ip address was provided by the dhcp from the router, and it has secondary attribute.

The weird thing is that, after the second execution, the guest can ping the host at 192.168.1.3 and at the "secondary" address.

Code is below.

Help sharing network connection between KVM guest and host

Following instructions given at (https://www.furorteutonicus.eu/2013/08/04/enabling-host-guest-networking-with-kvm-macvlan-and-macvtap/) in order to be able to reach my VM network from the host, I created a script that should create a macvlan bridge in the host.

Then I followed instructions from (How to write startup script for Systemd?) and (https://stackoverflow.com/questions/21830670/systemd-start-service-after-specific-service) to run the script on host startup.

The problem, however, is that the script doesn't do what it's supposed to, when it's first run. When I run it for a second time, despite an error message it works.
This error message I'm referring to is:

create_macvlan_bridge.sh[4489]: RTNETLINK answers: File exists

I reinforce that, despite this message, everything works as expected. But I'd like it to work correctly the first time. Can anyone help?

The issue is present whether I'm invoking the script directly or via systemctl start create_macvlan_bridge.

[Edit] When create_macvlan_bridge.service is enabled, after booting, I get this output for systemctl status:

create_macvlan_bridge.service - Create_macvlan_bridge
Loaded: loaded (/etc/systemd/system/create_macvlan_bridge.service; enabled; vendor preset: disabled)
Active: inactive (dead) since <datetime> <timezone>; 15s ago
Process: 492 ExecStart=/usr/local/bin/create_macvlan_bridge.sh (code=exited, status=0/SUCCESS)
Main PID: 492 (code=exited, status=0/SUCCESS)

<datetime> <hostname> systemd[1]: Starting Create_macvlan_bridge...
<datetime> <hostname> create_macvlan_bridge.sh[492]: ping: kernel.org: Name or service not known
<datetime> <hostname> create_macvlan_bridge.sh[492]: /usr/local/bin/create_macvlan_bridge.sh: Cannot ping kernel.org, waiting another 5 secs...
<datetime> <hostname> systemd[1]: Started Create_macvlan_bridge.

Script to create macvlan bridge on the host doesn't work unless it's run twice

I have a script that should create a macvlan bridge in the host when it starts up. The host is an up-to-date Arch Linux. This is intended to allow host and guest to share the same network. I found instructions given at:

https://www.furorteutonicus.eu/2013/08/04/enabling-host-guest-networking-with-kvm-macvlan-and-macvtap

(Regarding the execution at startup, I also consulted How to write startup script for Systemd? and https://stackoverflow.com/questions/21830670/systemd-start-service-after-specific-service).

The problem, however, is that the script is not effective at first try. It creates the macvlan device and the routing table, but doesn't make it possible for the host to ping the guest and vice-versa.

But when executed a second time, it works - that is, despite an error message which reads "create_macvlan_bridge.sh[4489]: RTNETLINK answers: File exists". Host can now ping guest as expected.

It's supposed to work at first try, though, and I can't figure out why it's not. Can anyone help?

[Update] I noticed the result of ip a shows a second inet entry for macvlan0@enp10s0 after the second execution:

macvlan0@enp10s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether da:a2:21:d1:95:24 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.3/24 scope global macvlan0
        valid_lft forever preferred_lft forever
    inet 192.168.1.22/24 brd 192.168.1.255 scope global secondary macvlan0
        valid_lft forever preferred_lft forever

Notice how this second ip address was provided by the dhcp from the router, and it has secondary attribute.

The weird thing is that, after the second execution, the guest can ping the host at 192.168.1.3 and at the "secondary" address.

Code is below.

forgot to update the file under /usr/local/bin
Source Link
Marc.2377
  • 1.2k
  • 1
  • 18
  • 44

create_macvlan_bridge.service - Create_macvlan_bridge
Loaded: loaded (/etc/systemd/system/create_macvlan_bridge.service; enabled; vendor preset: disabled)
Active: inactive (dead) since <datetime> <timezone>; 15s ago
Process: 492 ExecStart=/usr/local/bin/create_macvlan_bridge.sh (code=exited, status=0/SUCCESS)
Main PID: 492 (code=exited, status=0/SUCCESS)

<datetime> <hostname> systemd[1]: Starting Create_macvlan_bridge...
<datetime> <hostname> create_macvlan_bridge.sh[492]: ping: www.google.comkernel.org: Name or service not known
<datetime> <hostname> create_macvlan_bridge.sh[492]: /usr/local/bin/create_macvlan_bridge.sh: Cannot ping www.google.comkernel.org, waiting another 5 secs...
<datetime> <hostname> systemd[1]: Started Create_macvlan_bridge.

create_macvlan_bridge.service - Create_macvlan_bridge
Loaded: loaded (/etc/systemd/system/create_macvlan_bridge.service; enabled; vendor preset: disabled)
Active: inactive (dead) since <datetime> <timezone>; 15s ago
Process: 492 ExecStart=/usr/local/bin/create_macvlan_bridge.sh (code=exited, status=0/SUCCESS)
Main PID: 492 (code=exited, status=0/SUCCESS)

<datetime> <hostname> systemd[1]: Starting Create_macvlan_bridge...
<datetime> <hostname> create_macvlan_bridge.sh[492]: ping: www.google.com: Name or service not known
<datetime> <hostname> create_macvlan_bridge.sh[492]: /usr/local/bin/create_macvlan_bridge.sh: Cannot ping www.google.com, waiting another 5 secs...
<datetime> <hostname> systemd[1]: Started Create_macvlan_bridge.

create_macvlan_bridge.service - Create_macvlan_bridge
Loaded: loaded (/etc/systemd/system/create_macvlan_bridge.service; enabled; vendor preset: disabled)
Active: inactive (dead) since <datetime> <timezone>; 15s ago
Process: 492 ExecStart=/usr/local/bin/create_macvlan_bridge.sh (code=exited, status=0/SUCCESS)
Main PID: 492 (code=exited, status=0/SUCCESS)

<datetime> <hostname> systemd[1]: Starting Create_macvlan_bridge...
<datetime> <hostname> create_macvlan_bridge.sh[492]: ping: kernel.org: Name or service not known
<datetime> <hostname> create_macvlan_bridge.sh[492]: /usr/local/bin/create_macvlan_bridge.sh: Cannot ping kernel.org, waiting another 5 secs...
<datetime> <hostname> systemd[1]: Started Create_macvlan_bridge.

added 179 characters in body
Source Link
Marc.2377
  • 1.2k
  • 1
  • 18
  • 44
Loading
added 179 characters in body
Source Link
Marc.2377
  • 1.2k
  • 1
  • 18
  • 44
Loading
added 179 characters in body
Source Link
Marc.2377
  • 1.2k
  • 1
  • 18
  • 44
Loading
added 179 characters in body
Source Link
Marc.2377
  • 1.2k
  • 1
  • 18
  • 44
Loading
added 179 characters in body
Source Link
Marc.2377
  • 1.2k
  • 1
  • 18
  • 44
Loading
Source Link
Marc.2377
  • 1.2k
  • 1
  • 18
  • 44
Loading