Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

i have 3 network cards , 1 Lan (wired) , 1 wireless network card & 1 is wireless usb

how do i ping from specific network card ?

& how do i use specific network card for specific application


i want to ping google from wlan1

example for specific application

i want to use firefox or transmission from wan1

Lan ip > Working Properly enter image description here pin -I wlan1 enter image description here

route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    0      0        0 eth0     U     1000   0        0 eth0   U     0      0        0 vmnet8   U     1      0        0 eth0   U     2      0        0 wlan1   U     0      0        0 vmnet1

one@onezero:~$ ip route

default via dev eth0  proto static dev eth0  scope link  metric 1000 dev vmnet8  proto kernel  scope link  src dev eth0  proto kernel  scope link  src  metric 1 dev wlan1  proto kernel  scope link  src  metric 2 dev vmnet1  proto kernel  scope link  src 


one@onezero:~$ ping -S
PING ( 56(84) bytes of data.
64 bytes from ( icmp_req=1 ttl=236 time=391 ms
64 bytes from ( icmp_req=2 ttl=236 time=296 ms
64 bytes from ( icmp_req=3 ttl=236 time=393 ms
64 bytes from ( icmp_req=4 ttl=236 time=352 ms

 ping -S
PING ( 56(84) bytes of data.
64 bytes from ( icmp_req=1 ttl=236 time=312 ms
64 bytes from ( icmp_req=2 ttl=236 time=457 ms
64 bytes from ( icmp_req=3 ttl=236 time=298 ms
64 bytes from ( icmp_req=5 ttl=236 time=330 ms
64 bytes from ( icmp_req=6 ttl=236 time=300 ms

Now Lastly the application issue

share|improve this question

migrated from Jan 30 '12 at 20:09

This question came from our site for system and network administrators.

Do you just want to set the source address, or are you expecting to somehow select a different network path? Setting a source address is not going to auto-magically change which route is selected, and make exit any particular interface. – Zoredache Jan 30 '12 at 18:18

3 Answers 3

If you look at ping manual man ping, you can read:

-I interface address
   Set source address to specified interface address. Argument may be numeric IP
   address or name of device.
share|improve this answer
check 2nd pic > ping -I wlan1 – One Zero Jan 30 '12 at 15:05
Maybe, you have ping blocked in your connection. – Khaled Jan 30 '12 at 15:09
its working on eth0 – One Zero Jan 30 '12 at 15:16

Check out your routing table.

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    0      0        0 eth0   U     2      0        0 wlan1

Your wlan1 interface only knows how to reach the network. You also have your wlan1 and eth0 in the same subnet which could cause problems. You need to add a route to the routing table for any destinations you want to reach on your wlan interface. For example

route add -host gw dev wlan1
ping -I wlan1

Note this won't let you route by application. For that you'll need to configure policy routing with something like iptables -m owner --uid-owner The ping -S src_ip dest_ip command will actually send the packet out with a source of your wlan1 IP address but then route the packet out eth0 because the next hop is eth0 in the routing table. Your best bet is to place the wlan1 and eth0 interfaces on separate subnets.

share|improve this answer
thanks a alot... – One Zero Jan 31 '12 at 2:55

As far as ping goes, why don't you utilize -S switch of ping to simulate pinging from particular interface !

-S src_addr
             Use the following IP address as the source address in outgoing packets.  On hosts
             with more than one IP address, this option can be used to force the source address to
             be something other than the IP address of the interface the probe packet is sent on.
             If the IP address is not one of this machine's interface addresses, an error is
             returned and nothing is sent.

Application level awareness for network interface(IP addresses) is somewhat possible to some extent with if we specify different gateway for different interfaces or redirect traffic according to port or other criterion via firewall rules... eg. if you are using firefox to connect to 80 ports only , then you could specify SNAT rule in iptables to connect via yours specified IP address hence the desired interface

share|improve this answer
i didnt understand , command ? ping -S ? – One Zero Jan 30 '12 at 15:03
ping -S your.first.ip.addr & ping -S your.another.ip.addr pings with your available different IP address. If unspecified , default protocol takes the ping probe via default gateway – kaji Jan 30 '12 at 15:09
yes its working ...thanks – One Zero Jan 30 '12 at 15:18
What version of ping are you suing? On my Ubuntu system -S configures the socket send buffer. – Zoredache Jan 30 '12 at 18:20
ping -V > ping utility, iputils-sss20101006 – One Zero Jan 30 '12 at 18:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.