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?
Ubuntu – Having two different networks
networkingwireless
Related Solutions
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
.
For example,
$ 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 192.168.1.x/24
. A 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
Best Answer
As I understand from your question, your internet access works via WiFi and not via LAN. And you get your LAN connection settings via DHCP from your LAN router.
To access the internet you need to have the "default route" set to the router connected to the internet. Probably your LAN router's DHCP sets your default route to its own address.
As you did not provide any information about your OS (Ubuntu, kubuntu, xubuntu, any other?) it is difficult to give detailed advice. You may open a console terminal and type
netstat -nr
, which will give you sort of(sorry for the german system). What is important is the target (Ziel)
0.0.0.0
, which is the default route (address of the router to use when accessing internet). Try this command once without LAN connected and once with LAN connected and provide the output here for further assistance.Edit
Depending on what the LAN is for (connecting to other local computers, other networks behind the router), the easiest way to solve the problem would be to switch the LAN settings from "automatic (DHCP)" to "manual".
Start the network manager (should be some icon in your systray; in unity search for it - see the official documentation in the ubuntu wiki here, german version). Locate the connection called something like "Wired connection", select and click on "edit".
In the edit window, switch to tab "IPV4". Change the method from "auto (DHCP)" to "manual". Add a line to the address window (click on "add"). In the address window, enter a fixed address from your LAN and the corresponding netmask; leave the "Gateway" field empty. If there are other computers in your LAN getting their IP addresses via DHCP, make sure to use a fixed IP address outside the DHCP range of the router/DHCP server.
If there are other subnets which you want to reach via your LAN router, you have to add an entry for each of those subnets by clicking on "routes".
Save the changed configuration. Now when you connect the LAN, there will be no default gateway entry added to your routing table.