Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, I have a pc with two Ethernet interfaces linked by a cable. I'm trying to ping a interface from the other. What is the simplest way to do that? ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2013
    Posts
    3

    Ping between two interfaces in the same machine


    Hi,
    I have a pc with two Ethernet interfaces linked by a cable.
    I'm trying to ping a interface from the other.

    What is the simplest way to do that?
    what ip/mask and routes should I set?

    Thanks a lot!

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    hello and welcome, Ivanvv!

    i don't think you can do that easily. besides, why do you *want* to do that?

    you could always check the physical connection b/t the two, though, using ethtool. make sure both devices have the cable firmly plugged in, then:

    Code:
    ethtool eth0|grep Link\ detected
    ethtool eth1|grep Link\ detected
    You should see two links detected.

  3. #3
    Just Joined!
    Join Date
    Sep 2013
    Posts
    3
    Thks for your reply Atreyu!
    I want do that for validate network cards, measure bandwith, test fiber adapter with only one machine...
    Of course I have the link, "Echo Request" also when I add static route and arp entries but no Echo replies from the ping

  4. $spacer_open
    $spacer_close
  5. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by Ivanvv View Post
    Of course I have the link
    don't be so sure. that is a good test. it will identify:

    bad cards
    bad cables
    improperly inserted cables

    but yeah, doesn't help you much with the ping thing, i know.

    there is the -I flag to ping, to tell ping which interface to use, but as both NICs are on the same system, i don't think that will help, unless the kernel is somehow told (iptables? routing table?) to send packets bound for a specific network via a specific interface. as expected, the ping -I <host> command does not work for me. there is also nmap and the -e parameter to specify the NIC to use, but again, did not seem to work for me.

  6. #5
    Just Joined!
    Join Date
    Sep 2013
    Posts
    3
    I double checked ethool to be sure I 've the link before posting.
    yeah, ping $IP1 -I $ETH2 is the test I want to do.

    To do that,
    I've tried deleting all route and set:
    route add -host $IP1 dev $ETH2
    route add -host $IP2 dev $ETH1

    and fill manuely the arp table

    but all I have in both interface is "ICMP echo request" when I ping but nobody answers...

  7. #6
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    take a look at this StackOverflow thread. There are two solutions there that may interest you (related to my guesses; iptables and routing table). don't know if either work, of course. i'll let you figure that out!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •