Simulate Link down to Linux guests

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
Jermey
Posts: 12
Joined: 14. Aug 2015, 00:17

Simulate Link down to Linux guests

Post by Jermey »

Hi all,

I would like to programmatically make a Linux guest think that a link is up or down using the VBox API. I tried changing the cableConnected property. The net effect of this is from within the Linux guest, the link is still reported UP (i.e. using "ifconfig"), but traffic does stop. I would like Linux to report that the link is actually down; which would then cause other processes, such as routing and LLDP, to react accordingly.

Any ideas or suggestions would be greatly appreciated.

My host environment is Mac OS X, running VBox 5.0. I am programming in Python.

Thank you!!

Cheers,
-- Jeremy
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Simulate Link down to Linux guests

Post by noteirak »

Working fine on my end (in Java). Could you put a standalone code sample to illustrate your problem please?
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Jermey
Posts: 12
Joined: 14. Aug 2015, 00:17

Re: Simulate Link down to Linux guests

Post by Jermey »

Hi notelrak,

I was using the Virtual Box Manager (GUI) to simply change the cable connected state to "off". Once I did that I looked at the Linux ifconfig command and still saw the eth0 reporting link UP. So I didn't do this in programming just yet; I wanted to verify that actually changing the cable connected state had the desired effect.

I'll retest this since you've got this working on your system. Could you please let me know which version of Linux guest you are using; i.e. Ubuntu, Debian, version/etc.

Thank you!
-- Jeremy
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Simulate Link down to Linux guests

Post by noteirak »

I also did it with the GUI manager first before testing with code. So we have different results. I tried on a Lubuntu 14.02 LTS install (nothing fancy, default install settings)
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Jermey
Posts: 12
Joined: 14. Aug 2015, 00:17

Re: Simulate Link down to Linux guests

Post by Jermey »

Hi noteirak,

I just retested using my Python code, and it does in fact work. My apologies, I must have had something erroneous in my test environment.

Cheers,
-- Jeremy
Post Reply