Score:0

Set network route after starting docker container on ubuntu 20.04 TLS

kr flag

is there a possibility to add an additional route to the host table (ubuntu 20.04 LTS) with docker toolset after starting a docker container?

context:

  • Docker version 20.10.12, build e91ed57
  • installed wireguard as container (image: lscr.io/linuxserver/wireguard )
  • wireguard container has IP 172.19.0.2
  • wireguard network is 10.14.14.0
  • wireguard host peer has ip 10.14.14.1
  • wireguard clients peers have 10.14.14.2 3 4 and so on
  • a standard route will be created to route from host network to container network ( 192.168.2.0 → 172.19.0.0)
  • Setup Is Working so far, as long as all connections are built up by wireguard clients (they can connect to NAS in home network etc CIFS, WebDav, Webfrontend)

As soon as I want to use RDP, VoIP-client or other protocols where the server (e.g. rdp server) wants to establish a connection back to the client (e.g. rdp client) the setup isn’t working anymore.

EXCEPT I activate IP forwarding and set a route to 10.14.14.0 via 172.19.0.2 then also RDP and so on is working.

so far so good… but after a reboot the route disappears / is not there anymore of course. I am not able to set the route via netplan or so because the target isn’t available. Container needs to be started first.

Is there an option or possibility with docker toolset to run a script with the routing statement as soon as the wireguard container was started? Maybe I missed something.

This would be an more elegant option then to use standard linux approaches due to it relates to a docker context.

If there is no solution with docker toolset how could I achieve to set a route after the container was started?

best regards and thank you for your support

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.