I want to simulate unplugging a cable from a Linux instance. My initial response was ip link set eth0 down
. However, this command has impact on higher-level networking functions, e.g. routes (including default
route) are removed, etc. When I "plug it back in" with ip link set eth0 up
, the routes now are missing.
How can I simulate unplugged network without using down
, or conversely tell iproute2 to just cause the network cable to be disconnected?
Best Answer
Try this command:
To turn interface on, use this command.
Note: Please change
eth0
to your interface device.