How to Ping explicitly from eth1 instead of eth0

264

Solution 1

From the manual:

  -I interface
          interface is either an address, or an interface name.  If interface is an address, it sets source
          address to specified interface address.  If interface in an interface name, it sets source inter‐
          face  to  specified  interface.   For  ping6, when doing ping to a link-local scope address, link
          specification (by the '%'-notation in destination, or by this option) is required.

So, answer is:

ping -I eth1 123.123.123.123

Solution 2

Use the -I option -

-I interface address
          Set  source address to specified interface address. Argument may
          be numeric IP address or name of device. When pinging IPv6 link-
          local address this option is required.

ping -I eth1 www.google.com

Solution 3

I believe using the -I option will do this. I had to do it once, but that was some time ago. From the ping man page:

-I interface address
Set source address to specified interface address. Argument may be numeric IP address or name of device. When pinging IPv6 link-local address this option is required.

Share:
264

Related videos on Youtube

Jyina
Author by

Jyina

Updated on September 18, 2022

Comments

  • Jyina
    Jyina almost 2 years

    I am trying to deserialize a JSON string into a strongly typed Payment class as defined below. The JSON contains some name-value pairs in the items collection. How can I deserialize these into the ID and PersonName properties on my class?

    My JSON:

    {
      "status": 1,
      "amount": 200.0,
      "items": [
        {
          "name": "ID",
          "value": "123456"
        },
        {
          "name": "PersonName",
          "value": "test"
        }
      ]
    }
    

    My class:

    public class Payment
    {
        [DataMember]
        public string Status { get; set; }
    
        [DataMember]
        public string Amount { get; set; }
    
        [DataMember]
        public string ID { get; set; }
    
        [DataMember]
        public string PersonName { get; set; }
    }
    

    Here is how I am trying to deserialize it:

    var response = JsonConvert.DeserializeObject<Payment>(message);
    
    • David Schwartz
      David Schwartz almost 11 years
      What does it mean to execute a ping "with" an interface exactly?
    • Nkosi
      Nkosi over 5 years
      You will need to use a custom JsonConverter that knows how to interpret the items collection.