@selfhosted Have a commerical @wireguard vpn on my server. The problem i have is that if i use a docker, it does use the vpn interface with iptables, but if that goes down, the docker still goes through without the vpn interface. I have looked at iptables, but docker makes it own, and bit of a minefield. Any ideas? Thanks

  • aberrate_junior_beatnik (he/him)@midwest.social
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 years ago

    IMO the best way to ensure that traffic always goes through a VPN is to use network namespaces. The wireguard website has an article describing the process. In a nutshell, you create a dedicated namespace to put the physical interface in, create the wireguard interface in that namespace, then move the wireguard interface to the root (“normal”) namespace. That way the only way to get traffic out without the VPN is to run a program in that dedicated namespace.

  • Decronym@lemmy.decronym.xyzB
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    2 years ago

    Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I’ve seen in this thread:

    Fewer Letters More Letters
    IP Internet Protocol
    Plex Brand of media server package
    VPN Virtual Private Network

    3 acronyms in this thread; the most compressed thread commented on today has 11 acronyms.

    [Thread #482 for this sub, first seen 4th Feb 2024, 17:15] [FAQ] [Full list] [Contact] [Source code]

  • atzanteol@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    1
    ·
    2 years ago

    Maybe somebody else will provide more info, but by default docker usually creates a bridge for your containers called docker0 and uses the local system’s routing tables.

    You need to figure out how to either create a new docket network that only routes via the VPN or do that for your host as well.

  • socphoenix@midwest.social
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    2 years ago

    Docker on its own won’t think to look at that interface unless you tie it to it. Assuming you want to listen to both interfaces an external watchdog would be the call. You’d set the watchdog to look for iptables issues and then run commands if it went down (ie to restart iptables and then restart your containers).