ffmpeg - downmix and merge audio tracks

ffmpeg -i $SRC -ss 4:00 -filter_complex '[0:a:1]pan=2c|c0=c0|c1=c0[l];[0:a:0][l]amerge=inputs=2[a]' -map '0:v:0' -map '[a]' -c:v copy -c:a libvorbis -q:a 10 -ac 2 $DEST
        

This is what I do for preparing 5 minute ShadowPlay clips for playback in conventional applications.
We start with two audio tracks: first is stereo (game audio), second is stereo (mic) but the right channel is unused.

explanation

Select input and set start time to 4 minutes.
-i $SRC -ss 4:00
        

filter_complex

From input 0 (file at $SRC), get the second audio track (mic), and use pan to set both channels to the left channel signal. Save as 'l'.
    [0:a:1]pan=2c|c0=c0|c1=c0[l]
            
Merge the first and 'l' audio tracks into 'a'.
    [0:a:0][l]merge=inputs=2[a]
            
Select first video from first input, and select our synthesized audio track 'a'.
-map '0:v:0' -map '[a]'
        
Copy the video (do not re-encode), encode the audio with libvorbis (quality 10) with 2 channels.
-c:v copy -c:a libvorbis -q:a 10 -ac 2
        


iptables - IP forwarding/NAT

iptables -t nat -A PREROUTING --dport $LPORT -j DNAT --to-destination $TARGET_HOST:$RPORT
iptables -t nat -A POSTROUTING -j MASQUERADE
        
This will perform forwarding for requests that originate external from the host. The rule written here will forward requests sent to
$LPORT
to
$TARGET_HOST:$RPORT
. For this to work, the appropriate kernel modules need to be loaded, and IP forwarding needs to be enabled.
modprobe ip_tables
modprobe iptable_nat
sysctl net.ipv4.ip_forward=1 # for systemd
        

explanation

In the NAT table (for packets that create connections), append a rule to the PREROUTING chain.
-t nat -A PREROUTING
        
For requests to port
$LPORT
, rewrite the destination field as
$TARGET_HOST:$RPORT
. We do this in PREROUTING so that other filters can see the intended destination.
--dport $LPORT -j DNAT --to-destination $TARGET_HOST:$RPORT
        
Rewrite the source field as the packet is being transmitted to the target host. This can be done explicitly with
-j SNAT
if the IP address of the forwarding host is static. For packets returning from the target host, MASQ will look up which client is requesting them and send them back.
-t nat -A POSTROUTING -j MASQUERADE
        

tor - list IPv4 exit relays

nc -U $SOCKET << EOF | grep -E "^s.*Exit" -B1 | awk '/^r/ { print $7 }'
authenticate "$PASSWORD"
getinfo ns/all
quit
EOF
        
Run tor with
        ControlSocket $SOCKET