achevsmisle/openconnect-mikrotik-pi

By achevsmisle

Updated 16 days ago

Multiarch openconnect client: for mikrotik devices, RPi-like computers, amd64 as well

Image
Networking
0

1.8K

achevsmisle/openconnect-mikrotik-pi repository overview

Repository Description for Docker Image with OpenConnect

This Docker image is designed to run openconnect on Mikrotik devices, single-board computers (e.g., Raspberry Pi), and includes a build for the amd64 architecture. The entrypoint script configures a VPN connection using OpenConnect based on environment variables provided at runtime. Below is a table listing all expected environment variables with their descriptions, default values, notes, and whether they are required.

Functionality is tested against 1.6 or latest tag.

Environment Variables Table

VariableRequiredDescriptionDefault ValueValuesNotes
OC_USERit depends=)Username for the connectionNot setstringNecessary with password auth
OC_NO_PASSWDNoIf you don't use password authentication, set to 100,1I strongly advice not to use passwords
OC_PASSWORDNoPassword for the connectionNot setstringYour pass here. Unnecessary if OC_NO_PASSWD is set.
OC_KEYNoSSL key file name (mounted to /certs/)Not setstringUser SSL private key
OC_CERTNoCertificate file name (mounted to /certs/)Not setstringUser certificate
OC_MCERTNoCertificate file name (mounted to /certs/) = --mca-cert=Not setstringSecond (or machine) certificate
OC_MKEYNoCertificate file name (mounted to /certs/) = --mca-key=Not setstringSecond (or machine) SSL private key
OC_AUTHGROUPNoAuthentication group (used as --authgroup)Not setstringOptional, if required
OC_USERGROUPNoUser group (used as --usergroup)Not setstringOptional, if required
OC_SERVERYesServer address for the connection. Set port if it is not 443Not setstringhttps://your.domain.net[:port]
OC_IFACE_NAMENoName of the OpenConnect interfaceoc-tunstringChange if you want
OC_RECONNECT_TIMEOUTNoAfter disconnection or Dead Peer Detection, keep trying to reconnect for SECONDS30integerset the --reconnect-timeout seconds option
OC_PROTOCOLNoProtocol for OpenConnectanyconnectany supported protoLook for others in man openconnect
OC_SNINoSNI (Server Name Indication) for the connection=${OC_SERVER}any hostnameDefaults to the server address
OC_DEBUGNoDebug mode flag (0 - off, 1 - on)00,1Enables verbose mode and timestamps in logs
OC_PFSNoPerfect Forward Secrecy flag00,1Enables the --pfs option for OpenConnect
OC_SERVERCERT_FINGERPRINTNoServer certificate fingerprintNot sethashOptional, for server certificate verification. Look in openconnect man for --servercert option
OC_NO_SYSTEM_TRUSTNoFlag to disable trust in system certificates (0 - off, 1 - on)Not set0,1Enables --no-system-trust
OC_CAFILENoServer CA absolute file pathNot setstringOptional, if a custom CA is used
OC_NO_DTLSNoDisable DTLS (Additional UDP secure tunnel)00,1Enables --no-dtls
OC_DISABLE_IPV6NoDo not advertise IPv6 capability to server.00,1*Also applies sysctl -w net.ipv6.conf.default.forwarding=0 net.ipv6.conf.all.forwarding=0
OC_MTUNoSet the MTU for your connection1436integersets the --mtu VALUE option
OC_CAMOUFLAGE_SECRETNoSet the camouflage secret (will be appended to server address as https://your.domain.net/?your_secret)Not setstringAny valid value
OC_DEFAULT_ROUTENoSet the default IPv4/IPv6 route to tunnel10,1Must be enabled on Mikrotik devices. You can disable it on any other platform, where you control the kernel.
OC_CONTAINER_CUSTOM_ROUTE_IPV4NoSpace separated IPv4 subnet list in CIDR notation. Routes to them will be added via dev OC_CONTAINER_IFACE_NAME0stringUse this if you need.
OC_CONTAINER_CUSTOM_ROUTE_IPV6NoSpace separated IPv4 subnet list. Routes to them will be added via dev OC_CONTAINER_IFACE_NAME0stringUse this if you need.
OC_CONTAINER_IFACE_NAMEit depends=)Container network interface name (which leads to your net). It is strongly recommended to set this variable if you use OC_CONTAINER_CUSTOM_ROUTE_IPV4, OC_CONTAINER_CUSTOM_ROUTE_IPV6 or bothautosting**Yes, it has some fallback

* I like IPv6, but if you don't need it or don't know what it is, just disable it using the appropriate env variable.

** If you add custom routes, but don't set this var, there will be simple stupid fallback. It will search for NOT lo(loopback) and not OC_IFACE_NAME interface.

  • If it finds one => routes will be set via it.
  • If it finds > 1 (or no one) - violators will be shot, survivors will be shot again no routes will be added.
  • Also if you set the wrong name, it will not crash the container. Just...no routes will be added.

RouterOS

  • Container establishes connection with ocserv and shutdown correctly.
  • Traffic passes to server through tunnel.
  • It just works. Even with NAT66.
Warning
  • On mikrotik devices you should set routing manually!
  • For mikrotik devices you should apply the default route to your client (mikrotik) on VPN server, or do it there globally for all clients. RouterOS docker implementation forbids firewall rules addition - you can't masquerade inside the container.
  • Other firewall rules (forwarding) also should be set in RouterOS.

Last warning

  • entrypoint.sh in the container doesn't validate your string parameters! Be careful when you set them or suffer happy debugging.

Tag summary

Content type

Image

Digest

sha256:2c5d869c2

Size

13.5 MB

Last updated

27 days ago

docker pull achevsmisle/openconnect-mikrotik-pi