Wednesday, December 12, 2012

Proxy settings system wide for Linux Operating Systems

 
 The six (6) simple steps to set the system wide proxy settings,

Step 1: Installing redsocks 
  1. Firstly, download the following files: red sock file for 64 bit: redsocks_0.4+dfsg-1_amd64.deb and for 32 bit: redsocks_0.4+dfsg-1_i386.deb 
  2. Install redsocks with the command:
    • for 64 bit: $ sudo dpkg -i redsocks_0.4+dfsg-1_amd64.deb
    • for 32 bit: $ sudo dpkg -i redsocks_0.4+dfsg-1_i386.deb  
Step 2: Installing iptables 
  1. install iptables-persistent with the command
    • $ sudo apt-get install  iptables-persistent

Step 3: Configuring the redsocks
Create an empty file for redsocks.conf with the path /etc/redsocks.conf as $ sudo /etc/redsocks.conf
Copy the below code into it and also set your login and password

base {
    log_debug = off;
    log_info = off;
    log = "syslog:daemon";
    daemon = on;
    user = redsocks;
    group = redsocks;
    redirector = iptables;
}

redsocks {
    local_ip = 127.0.0.1;
    local_port = 5123;

    ip = 10.201.13.50;
    port = 80;

    type = http-relay;

    login = "user";
    password = "password";
}

redsocks {
    local_ip = 127.0.0.1;
    local_port = 5124;

    ip = 10.201.13.50;
    port = 80;

    type = http-connect;

    login = "user";
    password = "password";
}



Step 4: Configuring the rules v4
Create an empty file for rules.vs with the path /etc/iptables/rules.v4 as $ sudo /etc/iptables/rules.v4

Copy the below code into it,

*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A OUTPUT -d 10.0.0.0/8 -j RETURN
-A OUTPUT -d 127.0.0.0/8 -j RETURN
-A OUTPUT -d 192.168.0.0/16 -j RETURN

 

-A OUTPUT -p tcp --dport 443 -m tcp -j REDIRECT --to-ports 5124
-A OUTPUT -p tcp -m tcp -j REDIRECT --to-ports 5123
-A OUTPUT -p udp -m udp -j REDIRECT --to-ports 5123
COMMIT



Step 5: Setting startup variable to Yes

Change the startup variable to "yes" in the  /etc/defaults/redsocks.

Step 6: Final step
Remove proxy settings at browser or anywhere if you set up early and then restart the system. 


If you need any further help, please comment it below.

No comments:

Post a Comment