Debian Codegraph @

examples/port-forward/README.md

raw symbols SCIP
1 # Global Socket Port Forwarding
2 **Connect to a firewalled host**
3
4 **Problem**
5 A hypothetical example for BOB to connect to ALICE's IRCD. Both are on two different networks and behind a NAT/Firewall. Neither of them can reach the other.
6
7 **Objective**
8 Allow BOB to access ALICE's (private) IRCD service (without tampering with the firewall, NAT or router settings).
9
10 **Solution**
11 Create a port forward to ALICE's IRCD and make this forward accessible via the Global Socket Relay network (GSRN).
12
13 **Prerequisite**
14 IRCD running on ALICE's workstation and an IRC client (irssi) on BOB's workstation.
15
16 On workstation "ALICE" create */etc/system/systemd/gs-portforward.service* to configure a port forward from the Global Socket *ExampleSecretChangeMe* to TCP port 6667 on your workstation (127.0.0.1):
17 ```EditorConfig
18 [Unit]
19 Description=Global Socket IRCD Forward
20 After=network.target
21
22 [Service]
23 Type=simple
24 Restart=always
25 RestartSec=10
26 ExecStart=gs-netcat -s ExampleSecretChangeMe -l -d 127.0.0.1 -p 6667
27
28 [Install]
29 WantedBy=multi-user.target
30 ```
31
32 Start, check and enable the service:
33 ```ShellSession
34 root@ALICE:~# systemctl start gs-portforward
35 root@ALICE:~# systemctl status gs-portforward
36 root@ALICE:~# systemctl enable gs-portforward
37 ```
38
39 On BOB's workstation create a port forward from TCP port 6667 to the Global Socket *ExampleSecretChangeMe*:
40 ```ShellSession
41 b@BOB:~$ gs-netcat -s ExampleSecretChangeMe -p 6667
42 ```
43
44 TCP port 6667 on BOB's workstation is now forwarded to TCP port 6667 on ALICE's workstation. Bob connects to ALICE's IRCD as if the IRCD is running on his workstation (127.0.0.1):
45 ```ShellSession
46 b@BOB:~$ irssi -c 127.0.0.1
47 ```
48
49 Alternatively of using two separate commands BOB can use the *gsocket* tool to start the irc client and automatically forward the connection via the GSRN:
50 ```ShellSession
51 b@BOB:~$ gsocket irssi -c blah.gsocket
52 Enter Secret (or press Enter to generate): ExampleSecretChangeMe
53 =Secret :"ExampleSecretChangeMe"
54 =Encryption : SRP-AES-256-CBC-SHA-End2End (Prime: 4096 bits)
55 Irssi v1.2.0-2 - https://irssi.org
56 06:22 -!- Irssi: Looking up blahgsocket
57 06:22 -!- Irssi: Connecting to blah.gsocket [127.31.33.7] port 6667
58 [...]
59 ```
60
61 This is a hypothetical example. Alice can configure the port forward by changing 127.0.0.1 to the desired destination.
62
63 Alice created a port forward and started the IRCD service. Instead Alice can combine this into a single command:
64
65 ```ShellSession
66 alice@ALICE:~$ gsocket inspircd --nolog --nofork
67 Enter Secret (or press Enter to generate): ExampleSecretChangeMe
68 =Secret :"ExampleSecretChangeMe"
69 =Encryption : SRP-AES-256-CBC-SHA-End2End (Prime: 4096 bits)
70 Inspire Internet Relay Chat Server
71 (C) InspIRCd Development Team.
72 [...]
73 ```
74
75 Many more gs-netcat options are available: For example *-T* to connect via TOR or *-L* for log-output. See the manual page for gs-netcat.