4

I use a USB-Ethernet Adapter which gets recognized as eth1 in the target. I then set an IP for eth1 using the command

ifconfig eth1 YY.YY.YY.YY

When I use

ping -I eth1 XX.XX.XX.XX

OUTPUT :

mx6q:~# ping -I eth1 192.168.2.35
PING 192.168.2.35 (192.168.2.35): 56 data bytes
^C
--- 192.168.2.35 ping statistics --- 3 packets transmitted, 0 packets received, 100% packet loss

it's not working, whereas when I use

ping -I YY.YY.YY.YY XX.XX.XX.XX

OUTPUT :

mx6q:~# ping -I 192.168.2.99 192.168.2.35
PING 192.168.2.35 (192.168.2.35) from 192.168.2.99: 56 data bytes
64 bytes from 192.168.2.35: seq=0 ttl=64 time=0.765 ms
64 bytes from 192.168.2.35: seq=1 ttl=64 time=0.437 ms
^C
--- 192.168.2.35 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss

it is working.

What should I do to ping through interface name?

IFCONFIG

eth1      Link encap:Ethernet  HWaddr 00:07:40:53:dd:1b  
          inet addr:192.168.2.99  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::207:40ff:fe53:dd1b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:24 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
      RX bytes:4754 (4.6 KiB)  TX bytes:1376 (1.3 KiB)
6
  • How to configure the hosts ? - I am a beginner. Jul 5, 2016 at 9:39
  • What changes I've to do in it ? Jul 5, 2016 at 9:43
  • This works for me. Please say more about how it's "not working". Do you get an error message? What does the ping print out about what it's doing in the two cases? Does it help if you add -n to either command?
    – MAP
    Jul 5, 2016 at 10:31
  • @Rahul I don't think this has anything to do with his hosts file, since he's not using host names.
    – MAP
    Jul 5, 2016 at 10:32
  • It is working in my case
    – Ijaz Ahmad
    Jul 5, 2016 at 10:45

1 Answer 1

1

Make sure the interface name is present on your machine. Check by doing ifconfig or ip addr show or ip link show commands.

You can also do some troubleshooting using ip route show and traceroute -i commands.

It is working as shown below:

[iahmad@ijaz-cms ~]$ ping -I enp0s25 www.google.com

PING www.google.com (172.217.18.100) from 137.138.52.207 enp0s25: 56(84) bytes of data.
64 bytes from zrh04s05-in-f4.1e100.net (172.217.18.100): icmp_seq=1 ttl=54 time=4.88 ms
64 bytes from zrh04s05-in-f4.1e100.net (172.217.18.100): icmp_seq=2 ttl=54 time=4.97 ms
64 bytes from zrh04s05-in-f4.1e100.net (172.217.18.100): icmp_seq=3 ttl=54 time=5.01 ms
^C
--- www.google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 4.885/4.958/5.019/0.055 ms


[iahmad@ijaz-cms ~]$ ping -I 137.138.52.207 www.google.com

PING www.google.com (172.217.18.100) from 137.138.52.207 : 56(84) bytes of data.
64 bytes from zrh04s05-in-f4.1e100.net (172.217.18.100): icmp_seq=1 ttl=54 time=4.98 ms
64 bytes from zrh04s05-in-f4.1e100.net (172.217.18.100): icmp_seq=2 ttl=54 time=4.93 ms
64 bytes from zrh04s05-in-f4.1e100.net (172.217.18.100): icmp_seq=3 ttl=54 time=4.96 ms
64 bytes from zrh04s05-in-f4.1e100.net (172.217.18.100): icmp_seq=4 ttl=54 time=4.98 ms
^C
--- www.google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 4.939/4.966/4.983/0.017 ms
1
  • It is present in ifconfig. But the ping command doesn't work if we give the interface name instead of interface IP Jul 29, 2016 at 5:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .