Static IP address over wifi vs. ethernet

Gonna fiddle with setting up a pihole DNS server on an old laptop a bit this weekend and trying to remember how static IP addresses work.

I have a few different ways I connect to my network:

  1. Via wifi
  2. Plugging directly into the router
  3. Plugging into a switch which is plugged into a wall (which I assume is another switch ) which is plugged into the router

For ergonomic reasons, I would like to do my setup with the laptop here on my desk, and then move it over to the router closet when I’m done. Is it possible to set up a static IP address while the laptop is connected to wifi and then have it automatically figure out when I plug it into the router via ethernet that this is the same network (even though it’s a different network interface) and request the same, static IP?

Similarly… If I plug into the switch for setup, configure a static IP, and then plug directly into the router, will the static IP still carry through?

The easiest thing to do is to plug into the switch for setup (if it were me, I’d disable wifi entirely). You can’t assign the static IP to the wifi interface and have it automatically move to the physical interface. You’d have to jump through hoops.

But, as far as IP assignment is concerned, 2 and 3 are the same. IPs are assigned to the physical interface that’s connecting to the network. Whether that connection is through a switch or directly to the router doesn’t matter.

So if you plug into a switch for setup and assign a static IP to the physical interface, that IP will persist when you plug the physical interface directly into the router after setup. That’s the simplest way to do what you want.

1 Like

Just for clarity, the outlet in the wall isn’t another switch. It’s just a cable that runs from the wall to the router. It’s essentially an extension cord for your network.

I think it has to be a switch because there are multiple such wall outlets “powered” by only one cord from my router?

I’m a little worried that I muddied the question by getting into the network topology. So just to make sure I don’t wreck what you’re trying to do: you can definitely set up your pihole by plugging the laptop into the switch that’s connected to the wall.

The wall outlets are probably connected to a patch panel. A patch panel is a bit different from a switch. It basically fans out a connection from one port on your router to a bunch of different locations. This is what I did for the outlets in my house.

That said, it’s also possible that the router is going to a switch and each outlet is tied to a port on the switch. That would also work.

But I really didn’t mean to confuse the issue and I apologize for doing so. I just enjoy talking about this stuff. :sweat_smile:

Whether the wall outlets are connected to a switch or a patch panel, the setup will still work just fine if you plug your laptop into the switch by your desk.

You didn’t muddy the question, I was just following up out of casual interest. Thanks for letting me know about patch panels!

1 Like

There are at least a couple ways of getting a static IP: config file on the host or config the router to lease the same IP every time to a given MAC with DHCP.

Some hosts by default randomize their wifi MAC addresses so watch out for that in the DHCP case.

If setting up a static IP on the host it needs to be in the subnet and outside of the range that DHCP will hand out. You’ll need to configure the default gateway and DNS yourself too.

The wireless and wired interfaces could have roughly the same config, and you could set wireless not to enable automatically. If the wifi is off when you put it in the closet the ethernet that should be ok. Make sure the wifi doesn’t come up automatically on reboots.

If you want to go really wild you could have a virtual bridge or something. (Don’t do this.)

Yeah, just ignoring wifi and setting a static ip for the ethernet interface ended up being the easiest. Wifi would be a cool fallback if I were more paranoid about uptime, but it looks like if the pihole goes offline, my clients automatically fall back to the router DNS anyway so it’s no biggie.

Next thing I’m going to try is to configure the pihole as the DNS for the whole network (from my router settings) and see if the fallback behavior still works.

OK, so the new annoying problem is that my ethernet interface is actually an ethernet USB dongle and it seems to acquire a different interface name on every reboot, causing my static IP settings from nmcli to fail.

One thing that bit me recently in a similar setup: I had a DNS server I didn’t know about on IPv6, so watch out for that. To make matters worse it would discard responses for A records with local IP addresses.

I was going nuts because on my phone the browser could reach my services on my local host and some apps could not. This was because the browser does “happy eyeballs.”

What sort of name did you get?

I got enp0s20u1, so I guess type 3? The digit after the u is what changes. But it seems like it’s more stable now and the issue had to do with plugging the dongle into different usb ports

1 Like