3

I'm using Linux+QT for my OS system.

And here is what I'm facing the problem.

My Lan IP address is 172.16.120.17 and my wifi IP address is 172.16.120.20.

So I think they are in the same network segment.

Then I going to ping the address by using eth0.

And it works perfectly.

But When I ping it with wlan0 like below command.

ping -I wlan0 xxx.xxx.xxx.xxx

I can't ping the address.

After some testing, I find out that if I close down eth0 then wifi ping out as expect.(I'm doing with below command)

ifconfig eth0 down

If wifi and lan are in the different network segment then wifi and lan both can ping out as expect.

Why will this happened and how to fix it?

Or this is the normal phenomenon?

Thanks in Advanced!

dirkt
  • 31,679
  • 3
  • 40
  • 73
Tsung-Li Wang
  • 451
  • 1
  • 4
  • 9
  • 3
    This topic might be related to your issue: [How to have two network interfaces wifi and ethernet (as a backup) working together](https://unix.stackexchange.com/questions/212697/how-to-have-two-network-interfaces-wifi-and-ethernet-as-a-backup-working-toget) – Bumba laga Aug 25 '17 at 03:26
  • I try it but it still cannot solve my problem. – Tsung-Li Wang Aug 25 '17 at 05:54
  • Device bonding is the way to go. – fpmurphy Aug 25 '17 at 06:27
  • @fmurphy how would binding for the case that Ethernet and WiFi are connected to different subnets? – roaima Aug 25 '17 at 07:19
  • Please flush the route table `ip route flush table main` then restart the network `systemctl restart networking` – GAD3R Aug 25 '17 at 17:05

1 Answers1

2

Specifying the interface is not enough, you need to specify the source IP. See the man page for ping:

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

It is very likely your ping is going out with the source IP of eth0 which is messing things up.

HostFission
  • 347
  • 1
  • 7