Search code examples
network-programmingsalt-project

How to ping an address from specific interface by salt?


I know we can ping an address using command below(official doc):

salt '*' network.ping archlinux.org

but how to specify the interface? I know it should be possible because we can do it in terminal or command prompt:

windows:

ping  -4 192.168.0.1 -s 1

Ubuntu:

ping -I wlan0 8.8.8.8

so we can use salt '*' cmd.run "<command to execute>" but is there a better way?

thanks in advance


Solution

  • A quick check of the code reveals that this feature hasn't yet been added to the network.ping function. It doesn't look like it would be hard to add.

    Here's the function definition: https://github.com/saltstack/salt/blob/d7f242b9ca77dee0e80abb38d45493f1db609a65/salt/modules/network.py#L63

    Feel free to open an issue here: https://github.com/saltstack/salt/issues/new

    Or open a pull request if you'd like to add that functionality yourself.