2

I have two devices (actually not PC). Device A is connected with external network, this IP is 192.168.1.2, I use this as gateway. Device B has two interfaces like below. Two interfaces use the same gateway, so I set it manually. ping test fails (ping -I eth0 www.google.com / ping -I eth1 www.google.com)

What's wrong here?

eth0

IP : 192.168.1.1 mask : 255.255.255.252

eth1

IP : 192.168.1.11 mask : 255.255.255.248

Kernel IP routing table:

Destination Gateway Genmask Flags Metric Ref Use Iface

default 192.168.1.2 0.0.0.0 UG 0 0 0 eth0

default 192.168.1.2 0.0.0.0 UG 0 0 0 eth1

192.168.1.0 * 255.255.255.252 U 0 0 0 eth0

192.168.1.0 * 255.255.255.0 U 0 0 0 eth1

192.168.1.8 * 255.255.255.248 U 0 0 0 eth1

1

You have defined your gateway as being in two different places. You are saying that is it out of eth0 at 192.168.1.2 (which is correct), but also out of eth1 at 192.168.1.2 (which is incorrect). Not only is your gateway not available out of eth1, but the IP address isn't valid on that network.

Just remove the second gateway and it should work fine.

  • As you said, if I remove one, it works correctly. But it is working on only one interface. I hope that it can be used through different interface, if I try to connect different source IP using socket connection. – Victor Jun 7 '16 at 5:22
  • And I tested ping command, and captured and show pcap log. In log, outgoing and incoming packet is shown, but ping command is timeout about eth1. – Victor Jun 7 '16 at 5:24
  • What do you mean it is only working through one interface? The gateway only exists out of one interface. If you have other devices on 192.168.1.8 network, then you need to add routing to 192.168.1.2 to tell it to route packets for 192.168.1.8 via 192.168.1.1. Please edit your question and add more info. – Paul Jun 7 '16 at 5:31

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.