1

My machine is connected to a switch (using an ethernet cable). In addition to the modem (with built-in router) this switch is also connected to several other routers. Using a standard netctl profile (Interface=eth0, Connection=ethernet, IP=dhcp), I'm usually connected to the modem/router (192.168.100.1). However, today something went wrong — I got connected to one of the other routers (192.168.0.1).

I'm now wondering about the proper way to set-up a netctl profile to always connect to the 192.168.100.1 modem/router. One option might be to set IP=static and use something like Address=('192.168.100.42/24'), Gateway='192.168.100.1'. However, when I tried something random like Address=('123.123.123.42/24'), Gateway='123.123.123.1' netctl did not complain. The output of ip addr also displayed 123.123.123.42/24, even though there is no 123.123.123.1 router connected to the switch.

Basically my question is how to force netctl to connect to a certain router, using either IP=dhcp or IP=static.

2

First of all, it sounds like you have multiple routers in the same layer 2 domain (no problem so far) running different competing DHCP servers (problem). Generally there should only be a single DHCP server serving each subnet. There can be other routers (gateways toward other internal networks, etc...) but they should not run their own DHCP servers and certainly not in different subnets.

You are correct that, in the face of such a misconfiguration, using static addresses is a good workaround. You can manually configure a client to use one of the available competing subnets and one of the available competing routers. To do this, you will need:

  • The subnet in use. In this case it seems to be 192.168.100.0/24.
  • The available IP addresses that are not in the range of addresses given out by the DHCP server and also not assigned statically to other nodes, so that you do not choose an address that is actually or potentially already in use. Check the DHCP server configuration for the range of IP addresses that it hands out, and pick one that is not in that range.
  • The router IP address. In your case this appears to be 192.168.100.1.
  • DNS resolvers. These are normally handed out by the DHCP server, but when you are not using a DHCP server you have to set them manually.

The real solution is to not configure your network with multiple conflicting DHCP servers, and preferably not multiple conflicting IP subnets on the same layer 2 domain.

However, when I tried something random like Address=('123.123.123.42/24'), Gateway='123.123.123.1' netctl did not complain. The output of ip addr also displayed 123.123.123.42/24, even though there is no 123.123.123.1 router connected to the switch.

I'm not sure what your point is in this paragraph. 123.123.123.0/24 is not the correct IP address for your network, is it? Do you expect this to work?

  • Thanks! I'll look into that. As for the last bit, no I didn't expect it to work. Using IP=dhcp it usually takes 2-4 sec for netctl to establish a connection. With IP=static it seemed almost instantaneously, which I found a bit suspicious. That's why I tried something I knew shouldn't work, but was rather surprised that netctl didn't complain about it. – Ailurus Sep 12 '15 at 19:46
  • Yes, static is instantaneous because unlike DHCP it doesn't have to ask a server to please give it an address and wait for the answer. As for your second point, why would it complain? It did what you asked it to do, it configured that address on the interface... – Celada Sep 12 '15 at 19:51
  • Ah, I thought netctl actually sent a signal to the router at the indicated Gateway address and waited until the request was approved, regardless of using dhcp or static. – Ailurus Sep 12 '15 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.