REDIR(1)

πŸ’– REDIR(1) β€” the redirect TCP connections glow-up πŸ’–

System Manager's Manual · bestie edition, no cap ✨


✨ NAME ✨

redir β€” redirect TCP connections πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

redir [-hinpsv] [-b IP] [-f TYPE] [-I NAME] [-l LEVEL] [-m BPS]
      [-o <1,2,3>] [-t SEC] [-w MSEC] [-x HOST:PORT] [-z BYTES]
      [SRC]:PORT [DST]:PORT

πŸ’… DESCRIPTION πŸ’…

okay so picture this: redir takes TCP connections that show up on a local port, [SRC]:PORT, and sends them over to an address/port combo you picked, [DST]:PORT. that's the whole vibe. both the SRC and DST arguments can be left out btw β€” if you ghost them, redir will just use 0.0.0.0 instead. generous queen. πŸ‘‘

redir can run either from inetd or as a standalone daemon, and honestly it slays at both. in --inetd mode, the listening SRC:PORT combo is handled by another process β€” usually inetd β€” and a connected socket gets handed over to redir via stdin. so in --inetd mode only [DST]:PORT is required. only one. minimal. iconic. πŸŽ€

in standalone mode, redir can run either in the foreground with -n, or in the background, detached like a proper UNIX daemon. and that detached thing? that's the default. when you're running in the foreground, log messages also get printed to stderr β€” unless you pass the -s flag. so rude of them to talk over each other honestly.

heads up bestie: depending on how redir was compiled, not all options may be available. it's giving "depends on the build", fr fr. πŸ™ˆ

🌸 OPTIONS 🌸

mandatory arguments to long options are mandatory for short options too. equal opportunity requirements. periodt. πŸ’…

  • -b, --bind=IP β€” forces redir to pick a specific address to bind to when it listens for incoming connections. not applicable when you're running in Linux's transparent proxy mode, -p. (so don't try it there, she won't hear you 😭)
  • -h, --help β€” show built-in help text. the classic "hello?? explain yourself" button. ✨
  • -f, --ftp=TYPE β€” when you're using redir for an FTP server, this makes redir also redirect FTP connections. TYPE should be specified as either "port", "pasv", or "both", to specify what type of FTP connection to handle. note that --transproxy often makes one or the other (generally port) undesirable. so like, pick your fighter. πŸ₯Š
  • -i, --inetd β€” run as a process started from inetd(1), with the connection passed as stdin and stdout on startup.
  • -I, --ident=NAME β€” specify program identity (name) to be used for TCP wrapper checks and syslog messages. your name, your brand, your main character moment. πŸ‘‘
  • -l, --loglevel=LEVEL β€” set log level: none, err, notice, info, debug. default is notice. choose your volume, bestie. πŸ”Š
  • -n, --foreground β€” run in foreground, do not detach from controlling terminal. she stays. 🫢
  • -p, --transproxy β€” on a Linux system with transparent proxying enabled, this causes redir to make connections appear as if they had come from their true origin. see the file transproxy.txt in the distribution, and the Linux Documentation/networking/tproxy.txt for details. untested on modern Linux kernels β€” so like, proceed with caution, she's a little vintage. πŸ’€
  • -s, --syslog β€” log messages to syslog. this is the default, except when -n is enabled.
  • -t, --timeout=SEC β€” timeout and close the connection after SEC seconds of inactivity. ghosting, but scheduled. πŸ‘»
  • -v β€” show program version. tiny flag, big energy.
  • -x, --connect β€” redirects connections through an HTTP proxy which supports the CONNECT command. specify the address and port of the proxy using [DST]:PORT. --connect requires the hostname and port which the HTTP proxy will be asked to connect to. so like, it needs the deets. don't leave it on read. πŸ“¨

🌈 TRAFFIC SHAPING 🌈

the following options control traffic shaping, if redir is built with shaping enabled. conditional queen. 🧚

  • -m, --max-bandwidth=BPS β€” reduce the bandwidth to be no more than BPS bits/sec. the algorithm is basic, the goal is to simulate a slow connection, so there is no peak acceptance. she's not fancy, she's just slow. 🐌
  • -o, --wait-in-out=<1,2,3> β€” apply --max-bandwidth and --random-wait for input (1), output (2), or both (3). pick a lane, or don't. πŸ’…
  • -w, --random-wait=MSEC β€” wait between 0 and 2 x n milliseconds before each "packet". a "packet" is a block of data read in one time by redir. a "packet" size is always less than the bufsize (see also --bufsize). mystery timing, very mysterious of her. ✨
  • -z, --bufsize=BYTES β€” set the bufsize (default 4096) in bytes. can be used combined with --max-bandwidth or --random-wait to simulate a slow connection. slow and steady, bestie. πŸ“

😭 BUGS 😭

command line syntax changed in v3.0. compatibility with v2.x can be enabled using the --enable-compat configure option. this enables the following options: --laddr=ADDR --lport=PORT --caddr=ADDR --cport=PORT β€” which in v3.0 were been replaced with [SRC]:PORT and [DST]:PORT. (yes, the manpage said "were been". we're keeping it. character. πŸ’€)

for full compatibility, using any of these options will implicitly also enable -n. there is currently no way to tell redir to background itself in this mode of operation. so like, she's staying in the foreground whether you like it or not. no cap. 🫠


πŸ‘€ SEE ALSO πŸ‘€

inetd(1) uredir(1)


πŸ‘‘ AUTHORS πŸ‘‘

redir is written by Nigel Metheringham and Sam Creasey, with contributions from many others. it is currently being maintained at GitHub by Joachim Nilsson. shoutout to the whole squad, we love a collaborative slay. 🫢✨


and that's the page, bestie!! πŸ’– this one's from Debian, dated 01 May, 2016, and it lives under the name REDIR(1) β€” go forth and redirect responsibly, mwah πŸ’…πŸŽ€