(with its network adapter connected to the private, internal, and external networks) Maybe Ubuntu Desktop?) and see if you get similar results. it doesn't matter what network you connect to), try making a different VM (like some linux distro or something. (This may or may not work, and it may or may not be a good idea, but chances are it will give you more information for determining where exactly the problem lies.) You get a connected message on the internal network) remove your external network (From Hyper-V altogether), and try bridging the Network adapters (real ethernet and internal network) in the Host machine. You should be able to do this while the VM is running. Try connecting it to all three and see if anything changes. One private, one internal, and one external. Now, to find the cause of the problem, I would make 3 networks in the Virtual Switch Manager. On Debian based (like Ubuntu), you could store your scripts into /etc/network/if-down.In most cases, if the VM guest shows that the Ethernet cable is disconnected, it means that in the settings for the VM the Network Adapter's virtual switch is set to "Not connected." Obviously this doesn't seem to be the case for you, but double check to be safe. In fine, there must already be something about this.ĭepending on Linux Installation, you could add if-up and if-down scripts to be able to react to this kind of events. Nota: This require patch to be installed. sys/class/net/eth0/* 2>/dev/null |Ĭould render something like (once you've unplugged and plugged back, depending ): +++ - 14:18:29.577094838 +0100 sys/class/net/eth0/* 2>/dev/null >ethstate This is a pooling method, not a real event tracking. Reading or writting under /syscould break your system, especially if run as root! You've been warned -) If you need something more powerful, take a look at my NCD programming language, a programming language designed for network configurations.įor example, a simple NCD script that will print "cable in" and "cable out" to stdout (assuming the interface is already up): process foo d' The problem with doing network configurations with shell scripts is that shell scripts are terrible for event handling (such as a network cable being plugged in and out). ![]() Side note: if you use rtnetlink, you have to work together with udev, or your program may get confused when udev renames a new network interface. On the low level, these events can be caught using rtnetlink sockets, without any polling. I guess I can't put you both down as the correct answer? And its probably fair for you that I do choose one. Kent Fredric and lothar, both of your answers satisfy my need. How is the Linux world suppose to have their own version of the Windows bubble that pop up from the icon tray indicating that you've just unplugged the network cable? Isn't there some state which can be used in the /proc file system (everything else is in there)? Ping a host - since the product will be within a LAN using an unknown network configuration and unknown hosts.Using 'ifconfig' - since a network cable may be connected but the network not properly configured or not currently up.The following solutions which have been proposed on other sites do NOT work for this purpose: In a Linux environment, I need to detect the physical connected or disconnected state of an RJ45 connector to its socket.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |