Redirect Whonix-Workstation Ports or Unix Domain Socket Files to Whonix-Gateway

From Whonix
Jump to navigation Jump to search

Redirect ports or unix domain socket files from Whonix-Workstation localhost to Whonix-Gateway.

Introduction

[edit]

Port or unix domain socket file redirection could be useful for any future applications that expect Tor or the ControlPort to listen on any specific port or unix domain socket file that is not (yet) added to anon-ws-disable-stacked-tor build-insarchive.org iconarchive.today icon or configarchive.org iconarchive.today icon by default, or for any other port or unix domain socket file redirections from the workstation to the gateway.

Instructions

[edit]

To create a port or unix domain socket file, it is required to create and extend config file /etc/anon-ws-disable-stacked-tor.d/50_user.conf. [1]

1. Inside Whonix-Workstation.

2. Platform specific notice.

  • Non-Qubes-Whonix: No special notice.
  • Qubes-Whonix: users should use folder /etc/anon-ws-disable-stacked-tor.d rather than folder /usr/local/etc/anon-ws-disable-stacked-tor.d/ and apply this in whonix-workstation-18 Template. [2]

3. Create folder /usr/local/etc/anon-ws-disable-stacked-tor.d/.

sudo mkdir -p /usr/local/etc/anon-ws-disable-stacked-tor.d

4. Open file /usr/local/etc/anon-ws-disable-stacked-tor.d/50_user.conf in an editor with administrative ("root") rights.

1 Select your platform.

Non-Qubes-Whonix

2 Notes.

  • Sudoedit guidance: See Kicksecure logo Open File with Root RightsOnion network Logo for details on why using sudoedit improves security and how to use it.
  • Editor requirement: Close Featherpad (or the chosen text editor) before running the sudoedit command.

3 Open the file with root rights.

sudoedit /usr/local/etc/anon-ws-disable-stacked-tor.d/50_user.conf

Qubes-Whonix

2 Notes.

  • Sudoedit guidance: See Kicksecure logo Open File with Root RightsOnion network Logo for details on why using sudoedit improves security and how to use it.
  • Editor requirement: Close Featherpad (or the chosen text editor) before running the sudoedit command.
  • Template requirement: When using Qubes-Whonix, this must be done inside the Template.

3 Open the file with root rights.

sudoedit /usr/local/etc/anon-ws-disable-stacked-tor.d/50_user.conf

4 Notes.

  • Shut down Template: After applying this change, shut down the Template.
  • Restart App Qubes: All App Qubes based on the Template need to be restarted if they were already running.
  • Qubes persistence: See also Kicksecure logo Qubes PersistenceOnion network Logo
  • General procedure: This is a general procedure required for Qubes and is unspecific to Qubes-Whonix.

Others and Alternatives

2 Notes.

  • Example only: This is just an example. Other tools could achieve the same goal.
  • Troubleshooting and alternatives: If this example does not work for you, or if you are not using Whonix, please refer to Open File with Root Rights.

3 Open the file with root rights.

sudoedit /usr/local/etc/anon-ws-disable-stacked-tor.d/50_user.conf

5. Port redirection or unix domain socket file redirection.

A) Either add a port redirection.

For example to redirect Whonix-Workstation port 9100 to Whonix-Gateway port 9050. Note: adjust the port numbers for your needs.

file_port_tuples+=" port#9100:9050 "

B) Unix domain socket file redirection.

Create a unix domain socket file /var/run/anon-ws-disable-stacked-tor/unix-domain-socket-file.sock and have it forwarded to Whonix-Gateway port 9050.

file_port_tuples+=" /var/run/anon-ws-disable-stacked-tor/unix-domain-socket-file.sock#9050 "

6. Save.

7. Run the systemd-socket-proxyd systemd-unit-files-generator. [3]

sudo /usr/libexec/anon-ws-disable-stacked-tor/systemd-unit-files-generator

8. Done.

The process of creating a redirection is now complete.

Testing

[edit]

To test /var/run/anon-ws-disable-stacked-tor/unix-domain-socket-file.sock, you could use:

socat - UNIX-CONNECT:/var/run/anon-ws-disable-stacked-tor/unix-domain-socket-file.sock

Then type:

GET

Then press <enter>.

The expected reply includes Tor is not an HTTP Proxy.

Footnotes

[edit]
  1. https://github.com/Whonix/anon-ws-disable-stacked-tor/blob/master/etc/anon-ws-disable-stacked-tor.d/30_anon-dist.confarchive.org iconarchive.today icon
  2. The missing Qubes-Whonix feature is that /usr/libexec/anon-ws-disable-stacked-tor/systemd-unit-files-generator doesn't run at boot time and that files generated by /usr/libexec/anon-ws-disable-stacked-tor/systemd-unit-files-generator don't persist after reboot of a TemplateBasedVM.
  3. https://github.com/Whonix/anon-ws-disable-stacked-tor/blob/master/usr/libexec/anon-ws-disable-stacked-tor/systemd-unit-files-generatorarchive.org iconarchive.today icon
Notification image

We believe security software like Whonix needs to remain open source and independent. Would you help sustain and grow the project? Learn more about our 13 year success story and maybe DONATE!