My network keeps losing the gateway address

Hi.

Background:
I have a gateway to the internet through the hardware router at 192.168.1.1.
I have two network interfaces, a wired eth0 and a wireless wlan0.
The two interfaces have the same fixed IP address 192.168.1.2.
I use “traditional method with ifup” for configuring the network interfaces.
I encode the address 192.168.1.1 in the correct place for gateway in Yast’s Network card config GUI.

Problem:
An hour or so after I boot up, I lose the internet. When I look I find that the response to the command : route, changes from this:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 wlan0
link-local      *               255.255.0.0     U     0      0        0 eth0
loopback        *               255.0.0.0       U     0      0        0 lo
default         192.168.1.1     0.0.0.0         UG    0      0        0 wlan0

to this:

Kernel IP routing table                                     
(hangs here)

and I lose contact with the internet.

Sometimes if I run the command: rcnetwork restart, I get the correct behaviour back plus the internet back. But sometimes I don’t and I have to reboot. If I check in Yast Network Configuration GUI when computer has lost the internet, the code for the gateway is still there, even though the underlying network has lost it.

Is there a command or commands or a script I can write to run when this happens so I can restore the network’s knowledge of the location of the gateway?
[If there is such a script I would put it into a 5 or 10 minute repeating cron job until openSUSE 11.2 comes out – I don’t mind – “whatever works, works” I say.]
Or some other idea?

Thanks
Swerdna

Where I have both eth0 and wlan0. I use Network Manager.

Though I can’t see why you are experiencing issues. Has this just started happening?

I have a static LAN, so no need for “managing” network switching with a network manager.

Though I can’t see why you are experiencing issues. Has this just started happening?
No – my patience ran out, that’s all. And I suppose I exaggerated – maybe reboot needed only twice a day and “rcnetwork restart” succeeds in fixing it maybe twice a day – maybe total of four irritations per day.

Mmm, doesn’t sound like assigning the same network address to two interfaces is the right thing to do here. Why do you need to do that?

I don’t need to. I understood that it would be OK, so I left it like that. But I’ll turn one of them for 24 hours and see how it goes, and report back.

Thanks.

Turning one of the interfaces off fixed the problem.

I also use the same IP-address for both eth0 and wlan0 (because of port forwarding in my router) and with the right STARTMODE it is very convenient and absolutely reliable.

The important entries look like this.

eth0:

IPADDR='192.168.1.100/24'

IFPLUGD_PRIORITY='20'

STARTMODE='ifplugd'

wlan0:

IFPLUGD_PRIORITY='10'

IPADDR='192.168.1.100/24'

STARTMODE='ifplugd'

If cable is plugged in, eth0 is used exclusively and wlan0 is automatically deactivated, if I “go wireless” wlan0 is automatically activated on unplugging the cable.

To be sure that also eth0 will always be preferred if both interfaces are up (should normally not happen with ifplugd) setting metrics for the routing table is also an idea.

/etc/sysconfig/network/routes:

0.0.0.0 192.168.1.1 0.0.0.0 eth0 metric 10
0.0.0.0 192.168.1.1 0.0.0.0 wlan0 metric 5

(Can be set via YaST in the routing configuration)

@Akoellh

Thanks – I made those changes and will get back to report in 24 hours.

knock knock

What’s the actual status?

You should not have two interfaces sharing the same IP, as you don’t want the neighbours to have the same address you have.
In my network there are 2 PC’s dual-booting, even then I take care that the IP’s differ. If my son runs XP, his IP is …210, if he runs openSUSE it’s …211
Making wireless static brings a possible risk: You do need a gateway address, and that’s not going to be 192.168.1.1 everywhere.
Therefore I’d suggest you configure the wired interface with a static IP, the wireless with DHCP.

You are right, but you miss one out there:

“…at the same time” …

With the setup described above this cannot happen, as ifplugd takes care, that only one interface will be active at the same time.

Works here like a charm (since several years now).

What am I doing wrong. Heres “route”:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 wlan0
link-local      *               255.255.0.0     U     0      0        0 eth0
loopback        *               255.0.0.0       U     0      0        0 lo
default         192.168.1.1     0.0.0.0         UG    5      0        0 wlan0
default         192.168.1.1     0.0.0.0         UG    10     0        0 eth0

I have eth0 set to start on cable connect
I have wlan0 set to start on boot

eth0:

IPADDR='192.168.1.100/24'

IFPLUGD_PRIORITY='20'

STARTMODE='ifplugd'

wlan0:

IFPLUGD_PRIORITY='10'

IPADDR='192.168.1.100/24'

STARTMODE='ifplugd'

/etc/sysconfig/network/routes:

0.0.0.0 192.168.1.1 0.0.0.0 eth0 metric 10
0.0.0.0 192.168.1.1 0.0.0.0 wlan0 metric 5

In Yast under the routing tab there appears the above two routes and no “Default” Gateway.

Both cards are set to static IPs 192.168.1.2 and both stay active (unless I unplug eth0).

Is that what you intended? Then why two active cards?

I have wlan0 set to start on boot

No, you have to set it to “on cable connect” (which is actually “ifplugd”) although it might sound a bit strange.

Thanks – it’s working now. Slowly I begin to understand :\

For people reading this thread later:

Yes, “on cable connect” sounds strange for a wireless interface, the real meaning could be described as “if the interface has sucessfully joined a network”.

With wired connections this literally means plugging in a cable, with wireless it is just difficult to describe in a few words fitting in a small checkbox/dropdown menu, so it also says “on cable connect” there, although it sounds funny.

Joining a wireless network means that you are associated to the access point, so presumably this is checked by the ifup-scripts and ifplugd-demon for this option.

To give you an idea what it looks like, when you use this method:

A) only wireless:

ifconfig ; route -n
eth0      Link encap:Ethernet  Hardware Adresse MA:CA:DR:ES:SE
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets: errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 Sendewarteschlangenlänge:1000
          RX bytes:0 (0.0 Kb)  TX bytes:0 (0.0 Kb)
          Interrupt:217

lo        Link encap:Lokale Schleife
          inet Adresse:127.0.0.1  Maske:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:33 errors:0 dropped:0 overruns:0 frame:0
          TX packets:33 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 Sendewarteschlangenlänge:0
          RX bytes:2242 (2.1 Kb)  TX bytes:2242 (2.1 Kb)

wlan0     Link encap:Ethernet  Hardware Adresse MA:CA:DR:ES:SE
          inet Adresse:192.168.1.100  Bcast:192.168.1.255  Maske:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:19058 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17965 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 Sendewarteschlangenlänge:1000
          RX bytes:18459203 (17.6 Mb)  TX bytes:4731217 (4.5 Mb)

Kernel IP Routentabelle
Ziel            Router          Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 wlan0
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
0.0.0.0         192.168.1.1     0.0.0.0         UG    5      0        0 wlan0

B) plugging cable in:


ifconfig ; route -n
eth0      Link encap:Ethernet  Hardware Adresse MA:CA:DR:ES:SE
          inet Adresse:192.168.1.101  Bcast:192.168.1.255  Maske:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:58 errors:0 dropped:0 overruns:0 frame:0
          TX packets:74 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 Sendewarteschlangenlänge:1000
          RX bytes:29925 (29.2 Kb)  TX bytes:23373 (22.8 Kb)
          Interrupt:217

lo        Link encap:Lokale Schleife
          inet Adresse:127.0.0.1  Maske:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:33 errors:0 dropped:0 overruns:0 frame:0
          TX packets:33 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 Sendewarteschlangenlänge:0
          RX bytes:2242 (2.1 Kb)  TX bytes:2242 (2.1 Kb)

Kernel IP Routentabelle
Ziel            Router          Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
0.0.0.0         192.168.1.1     0.0.0.0         UG    10     0        0 eth0

C) removing cable:


ifconfig ; route -n
eth0      Link encap:Ethernet  Hardware Adresse MA:CA:DR:ES:SE
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:159 errors:0 dropped:0 overruns:0 frame:0
          TX packets:203 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 Sendewarteschlangenlänge:1000
          RX bytes:87646 (85.5 Kb)  TX bytes:66828 (65.2 Kb)
          Interrupt:217

lo        Link encap:Lokale Schleife
          inet Adresse:127.0.0.1  Maske:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:36 errors:0 dropped:0 overruns:0 frame:0
          TX packets:36 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 Sendewarteschlangenlänge:0
          RX bytes:2642 (2.5 Kb)  TX bytes:2642 (2.5 Kb)

wlan0     Link encap:Ethernet  Hardware Adresse MA:CA:DR:ES:SE
          inet Adresse:192.168.1.100  Bcast:192.168.1.255  Maske:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:19217 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18170 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 Sendewarteschlangenlänge:1000
          RX bytes:18797591 (17.9 Mb)  TX bytes:4870410 (4.6 Mb)

Kernel IP Routentabelle
Ziel            Router          Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 wlan0
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
0.0.0.0         192.168.1.1     0.0.0.0         UG    5      0        0 wlan0

Works like a charm and completely automatic.

The option


IFPLUGD_PRIORITY

takes care, that your wired connection will always be preferred if a cable is plugged in, as the priority for eth0 is higher than for wlan0 (which is the default).

Many thanks for the broad explanation