Created
May 13, 2024 10:34
-
-
Save andrewginns/ebbda325c5532113955414f40fb8796f to your computer and use it in GitHub Desktop.
Create a nordVPN-meshnet service that's accessible on any meshnet device
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
meshnet: | |
image: ghcr.io/mattstechinfo/meshnet:latest | |
networks: | |
app-meshnet: | |
ipv4_address: 172.20.0.2 | |
restart: unless-stopped | |
cap_add: | |
- NET_ADMIN | |
- NET_RAW | |
env_file: .env | |
hostname: meshnet | |
# This command setup redirects traffic to the meshnet-service container, then proceeds with the original meshnet startup sequence. | |
command: > | |
/bin/sh -c " | |
iptables -t nat -A PREROUTING -p tcp --dport 3000 -j DNAT --to-destination 172.40.0.3:3000 && | |
iptables -t nat -A POSTROUTING -j MASQUERADE && | |
nordvpn_login && meshnet_config && meshnet_watch | |
" | |
meshnet-service: | |
image: new-service-container:latest | |
env_file: .env | |
ports: | |
- "3000:3000" | |
networks: | |
app-meshnet: | |
ipv4_address: 172.20.0.3 | |
depends_on: | |
- meshnet | |
networks: | |
app-meshnet: | |
driver: bridge | |
ipam: | |
config: | |
- subnet: 172.20.0.0/16 |
Hey @andrewginns - I'm hoping to add a number of containers on a home server to my meshnet. I think this gist is what I need, but have a question... if I wanted to add multiple cointainered services, with distinct meshnet DNS addresses, would I need a compose file for each of the services?
@danpicton yes my understanding is that you'll need a new compose file. The mesh net container redirects all ports to the nordvpn provided address of the node.
Thanks - I suspected so. Still trying to bend this example to my use case, but hopefully not far off 😅
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
An example used for my fork of morphic is below