For example, to set your date/time according to your timezone:
# export http_proxy=http://proxy.mycompany.com:8080/ # date -s "$(wget -q -O - http://www.timeapi.org/gmt)"
Easy, right!
# export http_proxy=http://proxy.mycompany.com:8080/ # date -s "$(wget -q -O - http://www.timeapi.org/gmt)"
#!/bin/bash function generate_cert() { openssl genrsa -out $1.key 1024 openssl req -new -key $1.key -x509 -days 365 -out $1.crt cat $1.key $1.crt > $1.pem chmod 600 $1.key $1.pem } # Generate server certificate generate_cert socat_server # Generate client certificate generate_cert socat_client
socat -d -d OPENSSL-LISTEN:9111,bind=192.168.0.254,cert=socat_server.pem,cafile=socat_client.crt,reuseaddr,fork TUN:10.1.1.1/24,up
socat -d -d OPENSSL:5.6.7.8:9111,cert=socat_client.pem,cafile=socat_server.crt TUN:10.1.1.10/24,iff-up=1
socat TCP4-LISTEN:65432,bind=127.0.0.1,reuseaddr,fork PROXY:proxy.mycompany.com:5.6.7.8:9111,proxyport=3128 &
socat -d -d OPENSSL:127.0.0.1:65432,cert=socat_client.pem,cafile=socat_server.crt TUN:10.1.1.10/24,iff-up=1
iptables -t nat -A OUTPUT -p tcp -d google.com --dport 443 -j DNAT --to-destination 127.0.0.1:443
socat TCP4-LISTEN:443,bind=127.0.0.1,reuseaddr,fork PROXY:proxy.mycompany.com:google.com:443,proxyport=3128
iptables -t nat -D OUTPUT -p tcp -d google.com --dport 443 -j DNAT --to-destination 127.0.0.1:443
#!/bin/bash if [ -z $2 ]; then echo "usage: $0 <dest_host> <dest_port>" exit fi if [ $EUID -ne 0 ]; then echo "error: must be run as root" exit fi PROXYHOST=192.168.100.1 PROXYPORT=3128 # Forward all outgoing traffic directed to ext_host:ext_port to the loopback interface echo Creating rule... iptables -t nat -A OUTPUT -p tcp -d $1 --dport $2 -j DNAT --to-destination 127.0.0.1:$2 # use socat to tunnel connections to the local port through the proxy echo "127.0.0.1:$2 <--> $PROXYHOST:$PROXYPORT <--> $1:$2 (stop with ctrl+c)" socat TCP4-LISTEN:$2,bind=127.0.0.1,reuseaddr,fork PROXY:$PROXYHOST:$1:$2,proxyport=$PROXYPORT # remove created iptables rule echo Removing rule... iptables -t nat -D OUTPUT -p tcp -d $1 --dport $2 -j DNAT --to-destination 127.0.0.1:$2