Hiya, I’ve got a desktop (connected to wifi), and a server (without a networking card), and I do not have access to Ethernet/or the router. However, I do have a networking switch - and was wondering if I could bridge the WiFi from my desktop(Nobara), to the Switch, and have my other devices such as Raspberry Pi and my main server connect to that. If thats possible please let me know how, or point me to some resources, I believe I have to touch iptables in this case, but have never tweaked those before.

This is a very temporary solution for not having access to a router. But gotta live like this for 5 months, so gotta find a solution to get WiFi on my server, as cheap as possible.

  • Markaos@lemmy.one
    link
    fedilink
    English
    arrow-up
    3
    ·
    8 months ago

    Do you need other WiFi devices (like a phone or a laptop) to be able to access your servers? If not, you could just set up your desktop as a router, that would be the most painless way to go around this situation.

    The basic steps are to enable IP forwarding on your desktop, configure a static IP address on the Ethernet interface (for example 192.168.1.1/24 - just make sure it is in a different network than what you get from the WiFi. For example if you get 192.168.0.x, the previous example address would be fine), then optionally set up a DHCP server on the Ethernet interface (otherwise you will have to manually give everything a static IP address), and then finally add a masquerade rule into the firewall (something like iptables -A FORWARD -o wlp0s1 -i enp0s1 -m conntrack --ctstate NEW -j ACCEPT; iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT; iptables -t nat -A POSTROUTING -o wlp0s1 -j MASQUERADE - the first two rules allow new connections from Ethernet to WiFi and replies in either way, and the final rule sets up the masquerade - it makes it look like all the traffic is coming from your desktop and hides the new network from your WiFi router; it wouldn’t understand how to communicate with this new network otherwise)

    It might sound pretty overwhelming, but it should be manageable if you go step by step.

    • Lunch@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      8 months ago

      Thanks very much for a detailed response! Will try to dissect this and do this when I get home.

      Have great rest of your day 🙌

  • Possibly linux@lemmy.zip
    link
    fedilink
    English
    arrow-up
    2
    ·
    8 months ago

    I would personally do all the networking in a VM. You can create a VM with a virtual network interface connecting your machine to the VM and then use PCIe passthough to passthough WiFi and the network plug.

    This is much more complicated but it has the benefit of not screwing up your host system. If you break the VM you can roll it back or recreate it.

    • Lunch@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      8 months ago

      Thanks for this, although I did end up buying a WiFi extender to solve my issue. But will take notes of his for the future!

      • Possibly linux@lemmy.zip
        link
        fedilink
        English
        arrow-up
        2
        ·
        8 months ago

        That’s honestly a much better solution. I installed OpenWRT on one many years back and it worked just fine for providing networking for my homelab.

    • Markaos@lemmy.one
      link
      fedilink
      English
      arrow-up
      2
      ·
      8 months ago

      Pretty sure you can’t do that with standard WiFi. Or rather you kinda can, but you need to know how it’s different from Ethernet so you understand why everything keeps breaking.

      For example DHCP is absolutely out of the question, as it relies on the MAC address to assign IP addresses. So static IPs will be required. And you also need to make your “switch” aware of the fact that it now needs to route IP packets coming from WiFi, because everything on that side of the network will send the packets directly to the switch.

      • azdle@news.idlestate.org
        link
        fedilink
        English
        arrow-up
        1
        ·
        8 months ago

        Interesting, I swear I’ve done exactly this before and didn’t have DHCP troubles, but that was like a decade ago, so I might be misremembering.