You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-1Lines changed: 26 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,7 @@ In this diagram, the Client has generated and installed WireGuard configuration
36
36
-[Features](#features)
37
37
-[Demo](#demo)
38
38
-[Experimental](#experimental)
39
+
- [Localhost Server Access](#localhost-server-access)
39
40
- [TCP Tunneling](#tcp-tunneling)
40
41
- [Add Clients To Any Server](#add-clients-to-any-server)
41
42
@@ -85,7 +86,7 @@ See the [Usage section](#Usage) for more details.
85
86
86
87
No installation of Wiretap is required. Just grab a binary from the [releases](https://github.com/sandialabs/wiretap/releases) page. You may need two different binaries if the OS/ARCH are different on the client and server machines.
87
88
88
-
If you want to compile it yourself or can't find the OS/ARCH you're looking for, install Go (>=1.20) from https://go.dev/dl/ and use the provided [Makefile](./src/Makefile).
89
+
If you want to compile it yourself or can't find the OS/ARCH you're looking for, install Go (>=1.23.3) from https://go.dev/dl/ and use the provided [Makefile](./src/Makefile).
89
90
90
91
# How it Works
91
92
@@ -539,6 +540,30 @@ Please see the [Demo page in the Wiki](https://github.com/sandialabs/wiretap/wik
539
540
540
541
# Experimental
541
542
543
+
## Localhost Server Access
544
+
545
+
Sometimes you want to access many ports on the Server itself that are listening on the localhost/loopback interface instead of a public interface. Rather than setting up many individual port forwards, you can use Wiretap's "localhost IP" redirection feature.
546
+
547
+
When running the `configure` or `add server` commands, you can specify a `--localhost-ip <IPv4 address>` argument. For example:
Any packets received by this Server through the Wiretap network with this target destination address (`192.168.137.137` in this example) will be rerouted to the Server host's `127.0.0.1` loopback address instead, with replies routed back to the Client appropriately.
552
+
553
+
> [!CAUTION]
554
+
> It is **strongly** recommended that you specify a private (non-routable) IP address to use for this option, preferably one that you know is not in use in the target network. This feature has only been lightly tested, so if the re-routing fails unexpectedly you want to ensure your traffic will go to a "safe" destination. For similar reasons you should not specify a broadcast address, or IPs that your Client already has routes for.
555
+
556
+
Under the hood, this feature is roughly equivalent to adding this `iptables` rule to Wiretap's userspace networking stack on the Server:
- Currently this only works for TCP connections, and only for an IPv4 target address.
563
+
- Unfortunately there's [not a clean way](https://serverfault.com/a/975890) to do NAT to the IPv6 `::1` loopback address, so this feature can't be used to access services listening exclusively on that IPv6 address.
564
+
- This feature does not provide access to other IPs in the 127.0.0.0/8 space.
Copy file name to clipboardExpand all lines: src/cmd/add_server.go
+16-9Lines changed: 16 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ type addServerCmdConfig struct {
26
26
writeToClipboardbool
27
27
portint
28
28
nicknamestring
29
+
localhostIPstring
29
30
}
30
31
31
32
varaddServerCmdArgs=addServerCmdConfig{
@@ -37,6 +38,7 @@ var addServerCmdArgs = addServerCmdConfig{
37
38
writeToClipboard: false,
38
39
port: USE_ENDPOINT_PORT,
39
40
nickname: "",
41
+
localhostIP: "",
40
42
}
41
43
42
44
// addServerCmd represents the server command.
@@ -56,8 +58,9 @@ func init() {
56
58
addServerCmd.Flags().StringVarP(&addServerCmdArgs.serverAddress, "server-address", "s", addServerCmdArgs.serverAddress, "API address of server that new server will connect to, connects to client by default")
57
59
addServerCmd.Flags().IntVarP(&addServerCmdArgs.port, "port", "p", addServerCmdArgs.port, "listener port to start on new server for wireguard relay. If --outbound, default is the port specified in --endpoint; otherwise default is 51820")
58
60
addServerCmd.Flags().StringVarP(&addServerCmdArgs.nickname, "nickname", "n", addServerCmdArgs.nickname, "Server nickname to display in 'status' command")
61
+
addServerCmd.Flags().StringVarP(&addServerCmdArgs.localhostIP, "localhost-ip", "i", addServerCmdArgs.localhostIP, "[EXPERIMENTAL] Redirect wiretap packets destined for this IPv4 address to server's localhost")
59
62
addServerCmd.Flags().BoolVarP(&addServerCmdArgs.writeToClipboard, "clipboard", "c", addServerCmdArgs.writeToClipboard, "copy configuration args to clipboard")
60
-
63
+
61
64
addServerCmd.Flags().StringVarP(&addServerCmdArgs.configFileRelay, "relay-input", "", addServerCmdArgs.configFileRelay, "filename of input relay config file")
62
65
addServerCmd.Flags().StringVarP(&addServerCmdArgs.configFileE2EE, "e2ee-input", "", addServerCmdArgs.configFileE2EE, "filename of input E2EE config file")
63
66
addServerCmd.Flags().StringVarP(&addServerCmdArgs.configFileServer, "server-output", "", addServerCmdArgs.configFileServer, "filename of server config output file")
Copy file name to clipboardExpand all lines: src/cmd/configure.go
+28-18Lines changed: 28 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,7 @@ type configureCmdConfig struct {
35
35
keepaliveint
36
36
mtuint
37
37
disableV6bool
38
+
localhostIPstring
38
39
}
39
40
40
41
// Defaults for configure command.
@@ -61,6 +62,7 @@ var configureCmdArgs = configureCmdConfig{
61
62
keepalive: Keepalive,
62
63
mtu: MTU,
63
64
disableV6: false,
65
+
localhostIP: "",
64
66
}
65
67
66
68
// configureCmd represents the configure command.
@@ -82,7 +84,8 @@ func init() {
82
84
configureCmd.Flags().BoolVar(&configureCmdArgs.outbound, "outbound", configureCmdArgs.outbound, "client will initiate handshake to server; --endpoint now specifies server's listening socket instead of client's, and --port assigns the server's listening port instead of client's")
83
85
configureCmd.Flags().IntVarP(&configureCmdArgs.port, "port", "p", configureCmdArgs.port, "listener port for wireguard relay. Default is to copy the --endpoint port. If --outbound, sets port for the server; else for the client.")
84
86
configureCmd.Flags().StringVarP(&configureCmdArgs.nickname, "nickname", "n", configureCmdArgs.nickname, "Server nickname to display in 'status' command")
85
-
87
+
configureCmd.Flags().StringVarP(&configureCmdArgs.localhostIP, "localhost-ip", "i", configureCmdArgs.localhostIP, "[EXPERIMENTAL] Redirect wiretap packets destined for this IPv4 address to server's localhost")
configureCmd.Flags().StringVarP(&configureCmdArgs.configFileServer, "server-output", "s", configureCmdArgs.configFileServer, "wiretap server config output filename")
@@ -93,7 +96,7 @@ func init() {
93
96
configureCmd.Flags().IntVarP(&configureCmdArgs.keepalive, "keepalive", "k", configureCmdArgs.keepalive, "tunnel keepalive in seconds, only applies to outbound handshakes")
0 commit comments