I have an OpenWrt router with the IP of and I wanna redirect all the internet traffic to my ssh tunnel, this is the ssh command that I use:

ssh -o "ProxyCommand corkscrew 3339 %h %p" -vND 1080 username@serverip

This is my redsocks.conf please correct this as well if there's any problem:

base {
        // debug: connection progress & client list on SIGUSR1
        log_debug = on;

        // info: start and end of client session
        log_info = on;

        /* possible `log' values are:
         *   stderr
         *   file:/path/to/file
         *   syslog:FACILITY  facility is any of "daemon", "local0"..."local7"
        log = stderr;

        // detach from console
        daemon = off;

        /* Change uid, gid and root directory, these options require root
         * privilegies on startup.
         * Note, your chroot may requre /etc/localtime if you write log to syslog.
         * Log is opened before chroot & uid changing.
        // user = nobody;
        // group = nobody;
        // chroot = "/var/chroot";

        /* possible `redirector' values are:
         *   iptables   - for Linux
         *   ipf        - for FreeBSD
         *   pf         - for OpenBSD
         *   generic    - some generic redirector that MAY work
        redirector = iptables;

redsocks {
        /* `local_ip' defaults to for security reasons,
         * use if you want to listen on every interface.
         * `local_*' are used as port to redirect to.
        local_ip =;
        local_port = 12345;

        // `ip' and `port' are IP and tcp-port of proxy-server
        ip =;
        port = 1080;

        // known types: socks4, socks5, http-connect, http-relay
        type = socks5;

        // login = "foobar";
        // password = "baz";

redudp {                                                         
        // `local_ip' should not be as it's also used for outgoing
        // packets that are sent as replies - and it should be fixed      
        // if we want NAT to work properly.                               
        local_ip =;                                             
        local_port = 10053;                                               

        // `ip' and `port' of socks5 proxy server.                        
        ip =;                                                   
        port = 1080;                                                      
        //login = username;                                               
        //password = pazzw0rd;                                            

        // kernel does not give us this information, so we have to duplicate it
        // in both iptables rules and configuration file.  By the way, you can 
        // set `local_ip' to if you need more than 65535 ports to 
        // forward ;-)                                                         
        // This limitation may be relaxed in future versions using contrack-tools.
        dest_ip =;                                                        
        dest_port = 53;                                                           

        udp_timeout = 30;                                                         
        udp_timeout_stream = 180;                                                 

// you can add more `redsocks' and `redudp' sections if you need.       

How can I use redsocks to redirect my internet traffic to that ssh tunnel ? I want it to be like openvpn where I can just connect to my wifi and browse the internet, with ssh tunnel I have to set the proxy to socks port 1080 on the client side every time I want to redirect all my internet traffic to that tunnel. I'm new to linux and I'm stuck at the iptables command, I have read the instructions at http://darkk.net.ru/redsocks/ but I still can't get it to work. Please let me know the correct iptables command for my router above

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.