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!

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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