8

I am working from home on remote embedded Linux machine "X" via ssh. It has one physical network card.

I need to simulate Ethernet cable unplugged condition on the same remote machine "X" , while stay connected/working on it.

req1. ~The network oriented applications on "X" will "believe" they're disconnected as if I was unplugging the card in production scenario.

req2. I will be able to continue my remote (SSH) session although the situation in req1.

The remote box "X" uses systemd to load userland. if that's relevant.

Although I can plug "X" using serial port to another computer, into which I can remote from home, it won't solve my problem.

I've read the (PSB) following articles but I can't seem to combine them all into working solution.

Thanks!

virtual tap/tun here: http://backreference.org/2010/03/26/tuntap-interface-tutorial/

iproute2 features: http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2

virtual interface aliasing: https://serverfault.com/questions/83234/how-do-i-create-a-linux-virtual- network-interface-alias-with-a-real-interface?rq=1

forward traffic: Forward traffic coming into dummy interface on to another interface(?)

  • 2
    You would need to establish firewall rules that block the connections that you wish to test while making sure not to block your own. – Julie Pelletier May 14 '16 at 23:28
  • @JuliePelletier That would probably result in another kind of errors for the applications. Typically they would fail with "Connection timeout" instead of "Network unreachable". – lgeorget May 15 '16 at 08:57
  • 1
    @ReuelitBatPatish Have you had a look at network namespaces? https://lwn.net/Articles/580893/ They're the perfect tool to do network tests like disconnection and the like. – lgeorget May 15 '16 at 09:02
  • @JuliePelletier As far as I checked, Firewall rules wont make the interface card "beleive" it is in unplugged state. – Reuelit Bat Patish Jun 08 '16 at 22:56
  • @lgeorget I read the article. I need some hand holding here I guess, results where ssh are the only working connections, while the other network interface cards and their client apps "think" theyre disconnected. E.g, if i created a network namespace, how do I "convince" already running userspace processess to run in my newly set namespace? – Reuelit Bat Patish Jun 08 '16 at 22:59
  • 2
    @ReuelitBatPatish: If your applications can distinguish between a disconnected cable and a connection blocked by the firewall, they're focusing on the wrong things. – Julie Pelletier Jun 09 '16 at 03:51
  • @JuliePelletier: I am trying to simulate some environment. Where more than app do listen to network stack specifc notifications. And their behaviour change the flow for others. Trying to solve the problem at its core. Thanks for your kind help – Reuelit Bat Patish Jun 09 '16 at 04:54
  • 2
    @ReuelitBatPatish: Your main problem is that you impose yourself unrealistic limitations. Keeping an active connection while the low level media status gets changed is plainly impossible (other than a kernel hack which would be quite complicated and would not reflect a normal system). – Julie Pelletier Jun 09 '16 at 05:10
  • The best way to do that test is to have physical access to the system so that you can actually disconnect the cable, or you can also directly access the machine while you run your disconnection simulator without needing to maintain any connection. – Julie Pelletier Jun 09 '16 at 05:15
  • 1
    Without physical access, you could schedule a batch of tests that you could start and would output the different results in a file. At the end of that script, you put rules to ensure you get your access back :) – Julie Pelletier Jun 09 '16 at 05:17
  • If you need the interface to think the connection died, then you will have to lose your connection. But if you need the application to think the connection died, then it should be able to handle both firewall rules that block or reject specific types of traffic as well as a script that runs ifdown $interface ; sleep $time ; ifup $interface. – Jesusaur Aug 26 '16 at 01:08

2 Answers2

1

Use aliases look as best possible hit. But in this configuration only "interface down" situation can be simulated. Look impossible to clean simulate "Link down" situation.

For full test, management connection over serial port rather ssh can be used.

Your WS <-ssh-> Neighbor_to_testhost <-serial-> Test_Host
mmv-ru
  • 615
0

You don't say what kind of embedded device it is, but if it has an Intel IME then it might have IPMI which lets you connect on a different IP address and get a virtual serial connection.

If it's a tiny embedded device, you can usually run a cable from the JTAG header to a Raspberry Pi that you have configured as a terminal server with a USB to serial interface, ssh to the Raspberry Pi, then use e.g. 'screen /dev/ttyUSB0' to connect to the JTAG interface.

That way you can take the primary Ethernet down for real and test real-world results. Anything else and you'll miss circumstances that you can't simulate.