Connect to two networks

Dear openSuse users,

My netbook shall be connected to two networks at the same time. Network 1 is my internal ethernet network where certain devices are connected and operated. Network 2 is the house wlan router that gives access to the internet.

Network 1 has a fixed IP (192.168.10.200), Network 2 currently uses DHCP. I dont have direct access on the wlan router but could ask for it if required. Right now Network 1 works and Network 2 doesnt.

What shoud I do^^?

Some questions:

  1. Which opensuse version are you using?
  2. Which desktop (KDE or Gnome, for example) are you using?
  3. Is your system configured for “ifup” or for “NetworkManager”?

At present, your problem is not clear.

Maybe post the output from:


/sbin/ifconfig -a

and use code tags to post that. You can use the “#” near the top of the edit box to generate the code tags.

You may run into the problem that the system gives preference to ethernet (wired network). That is, it will attempt to route internet traffic via your wired connection. You will probably need to setup some manual routing to avoid that.

But first we need to know more about what you are doing (the questions above).

You need to answer nrickert’s questions. For the record, I’m using openSUSE 13.1 with Network Manager, and frequently connect to two networks during the course of my work in the manner you describe.

  1. openSuse 12.3 (Dartmouth) (i586)
  2. KDE 4.10.00 “release 1”
  3. I think NetworkManager, at least thats the only thing I encountered so far.
/sbin/ifconfig -a

 eth0      Link encap:Ethernet  Hardware Adresse 88:51:FB:C8:FF:0E   
           inet Adresse:192.168.10.200  Bcast:192.168.255.255  Maske:255.255.0.0
           inet6 Adresse: fe80::8a51:fbff:fec8:ff0e/64 Gültigkeitsbereich:Verbindung
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:3684 errors:0 dropped:0 overruns:0 frame:0
           TX packets:1238 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 Sendewarteschlangenlänge:1000  
           RX bytes:4702013 (4.4 Mb)  TX bytes:239036 (233.4 Kb)
 

 lo        Link encap:Lokale Schleife   
           inet Adresse:127.0.0.1  Maske:255.0.0.0
           inet6 Adresse: ::1/128 Gültigkeitsbereich:Maschine
           UP LOOPBACK RUNNING  MTU:65536  Metric:1
           RX packets:6677 errors:0 dropped:0 overruns:0 frame:0
           TX packets:6677 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 Sendewarteschlangenlänge:0  
           RX bytes:855303 (835.2 Kb)  TX bytes:855303 (835.2 Kb)
 

 wlan0     Link encap:Ethernet  Hardware Adresse F4:B7:E2:C6:4F:E1   
           inet6 Adresse: fe80::f6b7:e2ff:fec6:4fe1/64 Gültigkeitsbereich:Verbindung
           UP BROADCAST MULTICAST  MTU:1500  Metric:1
           RX packets:1173 errors:0 dropped:0 overruns:0 frame:0
           TX packets:1173 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 Sendewarteschlangenlänge:1000  
           RX bytes:149731 (146.2 Kb)  TX bytes:181815 (177.5 Kb)


Thanks for a help description that I can understand :P.

If you are using NetworkManager, there should be a network icon in the tray of your KDE panel (usually at the bottom right of the screen).

Maybe


ps -ef | grep Network

will tell you if NetworkManager is running.

If it is running, but you don’t have that icon, then right click on the tray, and click “System Tray Settings”. Then make sure that the box for “Network Management” is checked.

If you do have the icon, you should be able to use it to configure a WiFi connection. That will require the network key if network security crypto is in use. My memory of 12.3 and KDE, is that it works best if you select “System Connection” and “Connect Automatically” when setting it up, though that will prompt for the root password during the setup.

24641 24524 0 14:17 pts/1 00:00:00 grep  --color=auto Network

If you are using NetworkManager, there should be a network icon in the tray of your KDE panel (usually at the bottom right of the screen).

Yes there is. It was not started (might have something to do that I did the configuration with YAST?). I started it now. Sadly it doesnt show me a single connection when I go to “manage connections” (roughly translated from german).

I have the network key and the root password.

By contrast, this is what I get on my laptop:


% ps -ef | grep Network
root       730     1  0 09:09 ?        00:00:00 /usr/sbin/NetworkManager --no-daemon
root       894   730  0 09:10 ?        00:00:00 /sbin/dhclient -d -sf /usr/lib/nm-dhcp-client.action -pf /var/run/dhclient-wlp2s4.pid -lf /var/lib/NetworkManager/dhclient-27c72209-79e8-4621-bf26-45bf43d03ba4-wlp2s4.lease -cf /var/lib/NetworkManager/dhclient-wlp2s4.conf wlp2s4
rickert   1573  1445  0 09:13 pts/0    00:00:00 grep Network
% 

So, no, you are not currently running NetworkManager. You are apparently setup for “ifup”.

I suggest you start by trying to switch to using NetworkManager.

Yast –> Network Devices –> Network Settings

Click on the “Global Options” tab.

Select the box “User Controlled with Network Manager”

Presumably you will see that in German, but it should be easy enough to recognize.

Ok did that.

ps -ef | grep Network
18828 18801 0 17:34 pts/1 00:00:00 grep  --color=auto Network
25647     1 0 16:37 ?     00:00:00 /usr/sbin/NetworkManager  --no-daemon

Now it shows that both networks are connected but the wlan does not work.

I would expect the wlan to work locally – you should be able to ping other computer on the home network. But it won’t route to the Internet until some routing is configured.

I’ll have to experiment on my laptop, to see how to do that. I reply again later.

I’ve never needed to force routing, because I don’t have your two-network situation.

I’m assuming that you do have a wlan connection, and that you know the IP address of the router for that connection.

This is what should work:

Hold the mouse over the NetworkManager icon in the tray. Click “Manage Connections”

Select (click) the wlan connection that you are using, and then click “Edit”. You may be prompted for the root password.

Next, click the IPv4 tab.

When I do that, there’s a button that reads “Basic Settings”. I can switch that button to show “Routes”.

After that switch, I see a screen listing the routes. The initial list is empty.

Click “Add”.

In the first column (labeled “Address” here), type in “0” (without the quotes).
The second column (“Netmask”) should default to “255.0.0.0”, which is correct.
The third column (“Gateway”) needs the IP address of your router.
For the fouth column (“Metric”), enter “1” (without the quotes).

Save the results, and test whether you can now get to the Internet.

Hmm. You might have to do the same for the wired network. In that case, you will want
First column: “192.168.10.0”
Second column: “0.0.0.0”
Third column: the IP address for the wired router
Fourth column: “0” (without the quotes).
But also check the box “ignore automatically obtained routes”.

The reason for doing this for the wired network, is so that it won’t try to route Internet through the wired connection. I’m not actually sure if that will be needed.

I might have those netmask wrong. My output from “netstat -rn” gives:


Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.254.254 0.0.0.0         UG        0 0          0 enp4s0
127.0.0.0       0.0.0.0         255.0.0.0       U         0 0          0 lo
192.168.254.0   0.0.0.0         255.255.255.0   U         0 0          0 enp4s0

which seems to suggest that you need 0.0.0.0 for the netmask for wlan and 255.255.255.0 for the wired.

First, thanks for your answer, I will not forget it and try when Im getting to this stage at any point. I know the router ip and the wlan works (have verified this with the laptop Im writing this text on, which also can access the router). The netbook with openSuse however can not access the router. Also when I add such a routing and press OK nothing is saved…
For test reasons I unpluged the wired network and the wlan does not work, I think something is messed up. Can I do more diagnostic commands for you that you know whats going on?

That sounds like a messed up network. I run into that when I visit a particular relative.

Use the computer that can access the wlan. From there, find the IP address of the router and the MAC address of the router. You can usually get the MAC address with the command:


# arp -a

In Windows, the command “ipconfig” should give you the IP address of the router (listed as the default router). And “arp -a” should work in Windows, too, though it may give a MAC address using “-” instead of “:” as a separator between octets.

Then compare that with what you get on opensuse. At that relative’s house, my laptop gets the wrong MAC address for the router when running opensuse, but the right one with Windows. I have to force the right one with the “arp” command.

I probably haven’t been much help. You will have to do some investigation to work out what is going wrong. From this distance, I don’t even know what to look for.

Still thank you very much for the effort!

I will post again when I did some research (probably in some days).

Recommend

  • Use Network Manager if you aren’t already. It manages connecting to multiple networks better than YAST.
  • Never connect to a network with more than one physical adapter. For example, if you’re using wired and wireless is available (especially if both networks are configured with DHCP), manually turn off wireless with a physical switch or software (Install the Linux package rfkill). Vice versa, if you’re connecting using wireless, don’t also plug into the wired network.
  • If you wish in Network Manager to connect your networks automatically on boot instead of manually. Or, if you prefer to manually choose to start a network, don’t check the box… But remember you have to connect to the network, it won’t be done for you automatically.

Another request when you post, take a few moments to consider your Forum post’s subject line. In this case “connecting to two networks” is ambiguous because it’s possible to connect to multiple networks <simultaneously>. A clearer subject line might have included the fact you’re using a laptop and you want to different networks when you travel.

@nchert
Requiring arp is interesting. I can see especially if your machine is simply starting up from suspend/sleep/standby instead of a full bootup, arp re-advertises you to your network using a broadcast and all machines who hear your arp should respond. I wonder though if a more complete solution forcing updating with DHCP and its configuration is better with a network service restart. I also wonder if a feature request should be submitted to automatically arp (or network restart) when starting up from suspend.

HTH,
TSU