I need to use multiple network interfaces in a C program with sockets. My interfaces are wlan0 and eth0. When I connect eth0, the ping through wlan0 returns "Host unreachable", and consequently the socket who connects through wlan0 returns "connection timed out". If I run ifconfig, it returns 2 interfaces both UP and with an IP address. How can I connect both eth0 and wlan0?
EDIT:
My basic questions is: why i can't reach internet with wlan0 when eth0 is connected?
My routing tables:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0 0 eth0
10.0.0.0 0.0.0.0 255.255.255.0 U 9 0 0 wlan0
192.168.1.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
My iptables :
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ifconfig:
eth0 Link encap:Ethernet HWaddr 74:d0:2b:07:3a:dd
inet addr:192.168.1.129 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::76d0:2bff:fe07:3add/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:33194 errors:0 dropped:0 overruns:0 frame:0
TX packets:23759 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:31065847 (31.0 MB) TX bytes:3057118 (3.0 MB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:21018 errors:0 dropped:0 overruns:0 frame:0
TX packets:21018 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:10519343 (10.5 MB) TX bytes:10519343 (10.5 MB)
wlan0 Link encap:Ethernet HWaddr 6c:71:d9:5f:6b:7f
inet addr:10.0.0.6 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::6e71:d9ff:fe5f:6b7f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:34286 errors:0 dropped:0 overruns:0 frame:0
TX packets:26667 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:25986919 (25.9 MB) TX bytes:3409031 (3.4 MB)