Local Experiment Connections
Users can interact with materialized experiments through a direct Wireguard connection.
mrg has the ability to set this up for you, under the mrg local family of commands.
Prerequisites
mrg client
You will want to install the mrg client. If you do not have it, you can install it by downloading the appriopriate package here and either installing or extracting it somewhere.
We are working on making installation of the mrg client easier.
You should also have a version that is of v1.5.4 for the best experience. You can check the version by running:
mrg --version
If your binary is not up to date, you can run:
mrg update binary
Depending on where mrg is installed, you may need to run it under the appriopriate permissions.
Linux (including WSL and container environments)
On Linux, mrg uses the kernel Wireguard implementation, which has been present since kernel version 5.6 released around March 2020. If your kernel is relatively up to date, there is nothing that you have to do.
Windows
On Windows, mrg uses the official Windows Wireguard client. Please install it from here.
You will also need the appriopriate permissions to actually create the interface, which involves running it under administrator. Either run a terminal under administrator, or if you're in newer versions of Windows, use sudo for Windows.
MacOS
On MacOS, it requires wg-quick. This is not the version from the App Store, but rather, the command line version listed at the bottom of the install page.
So install it via:
brew install wireguard-tools
or
port install wireguard-tools
FreeBSD
On FreeBSD, it requires wg-quick, even if you have the kernel module installed. Follow the instructions at the bottom of the install page.
Configuration
The mrg client supports editing your /etc/hosts and your ssh config to make accessing your nodes as easy as possible.
/etc/hosts Modification
If you allow mrg to edit your /etc/hosts, your machine will be able to resolve the node names in your experiment.
These names will automatically be cleaned up when you detach your machine.
To allow mrg to edit your /etc/hosts, set it with mrg config set.
Unix-Like Systems (including MacOS)
mrg config set etchosts /etc/hosts
Windows
mrg config set etchosts "C:\Windows\System32\drivers\etc\hosts"
SSH Config Modification
If you allow mrg to edit your ssh config, your machine will be able to resolve the node names in your experiment when using SSH.
These configuration will automatically be cleaned up when you detach your machine.
To allow mrg to edit your sshconfig, set it with mrg config set.
mrg config set sshconfig ~/.ssh/config
When using Visual Studio Code, these names will also show up in the Remote Explorer, under the Remotes (Tunnel/SSH) section.
Attaching
Assume that you have an experiment called test.hello.olive:
sudo mrg local attach test.hello.olive
If you configured mrg to edit your /etc/hosts and/or your ssh config, they will be automatically modified when this command is run.
If you run mrg local attach while being attached to an experiment, you will be detached from your previous experiment first, you cannot be attached to two experiments simultaneously.
You can pass --dry to mrg local attach if you do not wish for it to make changes to your system. Instead, it will print out the Wireguard configuration that you would manually install. You could then take this configuration and install it on any device of your choosing, such as a phone with a Wireguard VPN app installed.
Detaching
sudo mrg local detach
If you configured mrg to edit your /etc/hosts and/or your ssh config, they will be automatically cleaned of any edits done by mrg.
Status
If you want to check the status of your local attachment, run:
sudo mrg local status
Implementation Details and Examples
/etc/hosts
This will insert lines into your /etc/hosts that look like the following:
# BEGIN MRG_BLOCK
172.30.0.1 infrapod.test.hello.olive.test infrapod moactl.test.hello.olive.test moactl
172.30.0.11 n0.infra.test.hello.olive.test n0
172.30.0.12 n1.infra.test.hello.olive.test n1
172.30.0.13 n2.infra.test.hello.olive.test n2
172.30.0.14 n3.infra.test.hello.olive.test n3
192.168.254.2 myblackboxnode.wgenc.test myblackboxnode
# END MRG_BLOCK
/etc/hosts Modification Example
olive@mergedev:~$ mrg config set etchosts /etc/hosts
olive@mergedev:~$ sudo mrg local attach test.hello.olive
INFO[0000] mrg is running under root, but we found the original sudo user. Using the original user's (olive) mrg configuration instead.
INFO local connection detached
INFO /etc/hosts had no mrg edits to clean, ignoring
INFO /home/olive/.ssh/config had no mrg edits to clean, ignoring
INFO using public key: FRzqx8alkWOy46OZI5guZpuwv9TDJQbgz2Bv17ETBQ4=
INFO enclave does not contain public key, adding
INFO local connection to test.hello.olive established
INFO successfully updated /etc/hosts
INFO successfully updated /home/olive/.ssh/config
olive@mergedev:~$ ping n0
PING n0.infra.test.hello.olive.test (172.30.0.11) 56(84) bytes of data.
64 bytes from n0.infra.test.hello.olive.test (172.30.0.11): icmp_seq=1 ttl=63 time=3898 ms
64 bytes from n0.infra.test.hello.olive.test (172.30.0.11): icmp_seq=2 ttl=63 time=2881 ms
64 bytes from n0.infra.test.hello.olive.test (172.30.0.11): icmp_seq=3 ttl=63 time=1856 ms
64 bytes from n0.infra.test.hello.olive.test (172.30.0.11): icmp_seq=4 ttl=63 time=833 ms
64 bytes from n0.infra.test.hello.olive.test (172.30.0.11): icmp_seq=5 ttl=63 time=0.657 ms
64 bytes from n0.infra.test.hello.olive.test (172.30.0.11): icmp_seq=6 ttl=63 time=0.770 ms
^C
--- n0.infra.test.hello.olive.test ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5113ms
rtt min/avg/max/mdev = 0.657/1578.395/3898.425/1454.443 ms, pipe 4
SSH Config Modification
This will insert things into your ssh config that look like the following:
# BEGIN MRG_BLOCK
Host n0.infra.test.hello.olive.test n0 172.30.0.11
Hostname 172.30.0.11
StrictHostKeyChecking no
Identityfile ~/.ssh/merge_key
User olive
UserKnownHostsFile /dev/null
LogLevel ERROR
Host n1.infra.test.hello.olive.test n1 172.30.0.12
Hostname 172.30.0.12
StrictHostKeyChecking no
Identityfile ~/.ssh/merge_key
User olive
UserKnownHostsFile /dev/null
LogLevel ERROR
Host n2.infra.test.hello.olive.test n2 172.30.0.13
Hostname 172.30.0.13
StrictHostKeyChecking no
Identityfile ~/.ssh/merge_key
User olive
UserKnownHostsFile /dev/null
LogLevel ERROR
Host n3.infra.test.hello.olive.test n3 172.30.0.14
Hostname 172.30.0.14
StrictHostKeyChecking no
Identityfile ~/.ssh/merge_key
User olive
UserKnownHostsFile /dev/null
LogLevel ERROR
# END MRG_BLOCK
SSH Config Modification Example
olive@mergedev:~$ mrg config set sshconfig ~/.ssh/config
olive@mergedev:~$ sudo mrg local attach test.hello.olive
INFO[0000] mrg is running under root, but we found the original sudo user. Using the original user's (olive) mrg configuration instead.
INFO local connection detached
INFO /home/olive/.ssh/config had no mrg edits to clean, ignoring
INFO using public key: rywqbVZVK/VGaCqUTFKHAse7ZH4U6SneaQhHO/MBYTs=
INFO enclave does not contain public key, adding
INFO local connection to test.hello.olive established
INFO successfully updated /home/olive/.ssh/config
olive@mergedev:~$ ssh n0
Welcome to Ubuntu 18.04.6 LTS (GNU/Linux 4.15.0-213-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
New release '20.04.6 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Wed Oct 21 19:53:32 2026 from 172.30.0.1
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
olive@n0:~$
Wireguard Blackbox Connections
You may want to make a device accessible to the experiment and other users without running a full Merge Facility, for example, to host a simple webserver.
You can allow other users to talk to your segment of the local connection with the following:
mrg local attach <realization>.<experiment>.<project> --mask 24
By default, other users will not be able to communicate to your device unless they also create a connection using the same command.
You can give a name for them to use with the --alias $ALIAS. If this is set, when the client sets up their side of the connection and /etc/hosts modification is enabled, they will be able to use the alias instead of the IP.
Here's a full example:
# on whatever you want to expose
olive@xdc-olive:~$ mrg local attach test.hello.olive --mask 24 --alias myblackboxnode
INFO detaching enclave: test.hello.olive, key: WPVxJ97804QXqcJceE+wo5Bb9UVVVzBPsw1SJ1201F0=
INFO local connection detached
INFO using public key: b77nJQdFZFqeL6JJGhDHJclipsxRqhu3jY2SZqGWkT8=
INFO enclave does not contain public key, adding
INFO local connection to test.hello.olive established
olive@xdc-olive:~$ ip -br -c addr | grep wg
wg-mrg-xdc-conn UNKNOWN 192.168.254.2/24
# on something else running the mrg client
olive@mergedev:~$ sudo mrg local attach test.hello.olive --mask 24
INFO[0000] mrg is running under root, but we found the original sudo user. Using the original user's (olive) mrg configuration instead.
INFO local connection detached
INFO /etc/hosts had no mrg edits to clean, ignoring
INFO /home/olive/.ssh/config had no mrg edits to clean, ignoring
INFO using public key: 05TMrUaDEp/Td/tuD987/xd80CdwGWn1Mev9WkR5Yh8=
INFO enclave does not contain public key, adding
INFO local connection to test.hello.olive established
INFO successfully updated /etc/hosts
INFO successfully updated /home/olive/.ssh/config
# this is the IP from before
ctran@mergedev:~$ ping 192.168.254.2
PING 192.168.254.2 (192.168.254.2) 56(84) bytes of data.
64 bytes from 192.168.254.2: icmp_seq=1 ttl=63 time=1.29 ms
64 bytes from 192.168.254.2: icmp_seq=2 ttl=63 time=1.20 ms
64 bytes from 192.168.254.2: icmp_seq=3 ttl=63 time=1.32 ms
# this machine has mrg config set etchosts /etc/hosts set
olive@mergedev:~$ ping myblackboxnode
PING myblackboxnode.wgenc.test (192.168.254.2) 56(84) bytes of data.
64 bytes from myblackboxnode.wgenc.test (192.168.254.2): icmp_seq=1 ttl=63 time=3083 ms
64 bytes from myblackboxnode.wgenc.test (192.168.254.2): icmp_seq=2 ttl=63 time=2049 ms
64 bytes from myblackboxnode.wgenc.test (192.168.254.2): icmp_seq=3 ttl=63 time=1026 ms
64 bytes from myblackboxnode.wgenc.test (192.168.254.2): icmp_seq=4 ttl=63 time=2.13 ms
64 bytes from myblackboxnode.wgenc.test (192.168.254.2): icmp_seq=5 ttl=63 time=1.32 ms
^C
--- myblackboxnode.wgenc.test ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4082ms
rtt min/avg/max/mdev = 1.319/1232.297/3082.749/1196.872 ms, pipe 4
Local XDCs
Local connections also allow you to run a local XDC and attach it to an experiment without having to run an XDC on the portal. Using docker, this is the command:
docker run --pull=always --rm --cap-add=NET_ADMIN --cap-add=NET_RAW -it registry.gitlab.com/mergetb/portal/services/xdc/xdc-base-tiny:latest
Here's a full example using docker:
olive@mergedev:~$ docker run --pull=always --rm --cap-add=NET_ADMIN --cap-add=NET_RAW -it registry.gitlab.com/mergetb/portal/services/xdc/xdc-base-tiny:latest
olive@mergedev:/# mrg login olive
olive@mergedev:/# mrg local attach test.hello.olive
WARN[0000] mrg is running under root. Note that mrg configurations and tokens are stored per user, so mrg will need to be reconfigured under the root user.
INFO[0000] upgraded mrg config
INFO detaching enclave: test.hello.olive, key: 05TMrUaDEp/Td/tuD987/xd80CdwGWn1Mev9WkR5Yh8=
INFO local connection detached
INFO successfully cleaned /etc/hosts of mrg edits
INFO using public key: mDsTva3+NK14SmNk5jPWTgxJGHxtmZtIrRMG7y1w5Rg=
INFO enclave does not contain public key, adding
INFO local connection to test.hello.olive established
INFO successfully updated /etc/hosts
INFO successfully updated /root/.ssh/config
olive@mergedev:/# ping n0
PING n0.infra.test.hello.olive.test (172.30.0.11) 56(84) bytes of data.
64 bytes from n0.infra.test.hello.olive.test (172.30.0.11): icmp_seq=1 ttl=63 time=2065 ms
64 bytes from n0.infra.test.hello.olive.test (172.30.0.11): icmp_seq=2 ttl=63 time=1025 ms
64 bytes from n0.infra.test.hello.olive.test (172.30.0.11): icmp_seq=3 ttl=63 time=1.71 ms
64 bytes from n0.infra.test.hello.olive.test (172.30.0.11): icmp_seq=4 ttl=63 time=0.898 ms
64 bytes from n0.infra.test.hello.olive.test (172.30.0.11): icmp_seq=5 ttl=63 time=0.736 ms
We currently only publish x86_64 containers for XDC base images.
Since we're just using docker run, you can customize you run your container however you want. A common thing to do would be to mount the current directory, an example would be to add -v .:/work like so:
docker run --pull=always -v .:/work --rm --cap-add=NET_ADMIN --cap-add=NET_RAW -it registry.gitlab.com/mergetb/portal/services/xdc/xdc-base-tiny:latest
You can go here for a list of supported docker arguments.
Local XDC Variants
We publish different XDC variants, depending on your needs:
| Image | Description |
|---|---|
| registry.gitlab.com/mergetb/portal/services/xdc/xdc-base-tiny:latest | The smallest local XDC image, only having basic utilities (SSH, rsync, ping, and mrg) to connect to experiment nodes. |
| registry.gitlab.com/mergetb/portal/services/xdc/xdc-base-minimal:latest | A larger local XDC image meant for more intensive experimentation, containing everything in the previous image along with ansible and python3-pip. |
| registry.gitlab.com/mergetb/portal/services/xdc/xdc-base:latest | The largest XDC image, which is run by default in the portal. While this is not intended to be to be run locally, you still can run it. Use bash as the entrypoint. |