My computer is connected two networks, one is company network (internet) over WiFi, so I can not change my IP address or other settings on this network, second is a local LAN network to which my computer is connected with cable. this local LAN has a router and I can change settings on this cabled-network. But If I activate both networks at the same time, internet connection does not work any more. If I unplug the local LAN cable or deactivate it, then internet connection over WiFi works. I have read somewhere that, If you have two different networks, then all settings should be manual, I mean IP addresses, gateways, netmasks etc. Since I can not change these settins of WiFi network, how can I have working 2 networks?
I'm assuming you don't have any routes set locally on the Ubuntu box.
If your target IP address shares address space with the directly connected interface, it should by default route to the correct IP.
You will be able to see what networks your interfaces 'own' with
ip route show.
$ ip route show 192.168.2.0/24 dev eth0 proto kernel scope link src 192.168.2.22 metric 1
In this case, a
192.168.1.x/24 address (eth0) would be the gateway for the the same
10.x.x.x address will be the gateway for all
10.x.x.x that fall under its subnet mask.
This is actually what you see in bacon's answer. It shows a ping test where the gateway and target IP addresses are in the same network -- the network masks match exactly.
192.168.43.102 is within the same
/24 network (as indicated by the
255.255.255.0 network mask) as the interface.
The only problem would be confusion over other subnets -- the interface connecting to the outbound ISP path would need to be the 'gateway of last resort' for all routes that aren't directly connected.
You can get this to work, but you should do a quick test to make sure you can reach the resources you need.
You might find that you need to use
route add to add a default route.
You sure can. You didn't specify it, but I'm assuming you get the IP address automatically (via DHCP) both on wireless and wired connection.
Wired Ethernet is faster than wireless, so if there are two ways to get somewhere, wired will takes precedence over Wi-Fi by default. With that said, when you connect to both links, both DHCP servers by default will advertise themselves as the default gateway for all of the traffic.
So now your computer thinks it has two ways to connect to the Internet, and since wired is preferred it'll send traffic for the Internet via Ethernet. If that's the case, you would see two gateways for default networks 0.0.0.0 in your routing table,
route -n, one with your wireless router as a gateway and one for the wired.
But the Metric for the Ethernet gateway would be lower than wireless, so your PC will send the packets there. Now that your Ethernet router gets them, it doesn't know what to do with them, so it just drops them. The order where you connected first shouldn't matter.
As far as fixing (this assumes the DHCP case), the correct way would be to tell the LAN router to stop advertising itself as the default gateway. You need to log in to the router and look through settings. If you have no control over the router, you can remove it from your end with:
route del default gw eth.router.ip.address