How to create Ethernet interface at a specific IP address that I can ping and force to sometimes reply and sometimes not?
0
votes
3
answers
1678
views
I'd like to do some experiments to test the
ping
and fping
commands (see: https://unix.stackexchange.com/questions/678045/equivalent-of-ping-o-on-linux) , but I need a local virtual Ethernet interface to test this.
I'd like to have a scenario where I can run ping 10.0.0.1
(or any other IP) and have it fail. Then, while ping
is still running, I run some commands that bring up the interface and have it pass. In other words, the output of ping
will change _while it is running_, as the virtual device comes "alive". I don't want to have to use physical hardware.
How can I do this?
I've already tried following my own instructions here (https://unix.stackexchange.com/questions/152331/how-can-i-create-a-virtual-ethernet-interface-on-a-machine-without-a-physical-ad/593142#593142) , but unfortunately even after running sudo ip link set eth10 down
, pinging eth10 via ping 10.0.0.1
still succeeds. After running sudo ip link delete eth10 type dummy
to delete the dummy virtual device, ping 10.0.0.1
also still succeeds.
---
## Summary of functional answers so far:
(as of 22 Nov. 2021)
3 answers received (my own included), and **all 3 answers work**!:
1. [by Stephen Harris](https://unix.stackexchange.com/a/678208/114401) - use loopback sub-interfaces (probably the best answer so far)
1. [by Hauke Laging](https://unix.stackexchange.com/a/678181/114401) - use iptables
1. [my own answer](https://unix.stackexchange.com/a/678180/114401) - use virtual interfaces
Asked by Gabriel Staples
(2972 rep)
Nov 18, 2021, 09:07 PM
Last activity: Nov 22, 2021, 07:47 AM
Last activity: Nov 22, 2021, 07:47 AM