redsocks help as socks redirector

Support for security such as Firewalls and securing linux
squidcentos
Posts: 78
Joined: 2013/01/19 13:04:07
Contact:

redsocks help as socks redirector

Postby squidcentos » 2015/08/03 10:02:48

Hi Guys
i want to ask
i need redsocks on centos

http://darkk.net.ru/redsocks/

is there is a package i can install like yum install redsocks ?

or compile it from source ??

i searched but didn't find

anyhelp ?

cheers

aks
Posts: 2489
Joined: 2014/09/20 11:22:14

Re: redsocks help as socks redirector

Postby aks » 2015/08/03 16:34:17

I've never tried it, but this guy reckons this is how you go about it: http://linuxaria.com/article/redirect-a ... y-in-linux
(it's downloading a binary I think).
Dag and repoforge used to offer Dante. I think ss5 is "in the queue" for EPEL.

squidcentos
Posts: 78
Joined: 2013/01/19 13:04:07
Contact:

Re: redsocks help as socks redirector

Postby squidcentos » 2015/08/03 16:54:08

i have seen this before
and seems that the guy is not knowing wt is he doing

i didnt see anyone talk about centos so far !!

squidcentos
Posts: 78
Joined: 2013/01/19 13:04:07
Contact:

Re: redsocks help as socks redirector

Postby squidcentos » 2015/08/03 18:54:18

Hey Guys
i have ubuntu 14 / installed with redsocks and i have about 2 socks servers that authorize my server public ip.

i 2 private subnets
192.168.10.0/24
and
192.168.20.0/24
==========
root@VPNSOCKS:~# ifconfig
eth0 Link encap:Ethernet HWaddr 04:01:61:49:10:01
inet addr:xxxxx.231.2 Bcast:104.236.255.255 Mask:255.255.192.0
inet6 addr: fe80::601:61ff:fe49:1001/64 Scope:Link
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:330652 errors:0 dropped:0 overruns:0 frame:0
TX packets:343397 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:169157110 (169.1 MB) TX bytes:75439675 (75.4 MB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:785404 errors:0 dropped:0 overruns:0 frame:0
TX packets:785404 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:47633173 (47.6 MB) TX bytes:47633173 (47.6 MB)

tap_axp1 Link encap:Ethernet HWaddr 00:ac:ac:fd:31:28
inet addr:192.168.10.1 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::2ac:acff:fefd:3128/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:31 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:298 (298.0 B) TX bytes:1818 (1.8 KB)

tap_axp2 Link encap:Ethernet HWaddr 00:ac:4a:cf:93:1f
inet addr:192.168.20.1 Bcast:192.168.20.255 Mask:255.255.255.0
inet6 addr: fe80::2ac:4aff:fecf:931f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:172 (172.0 B) TX bytes:1062 (1.0 KB)

================

now what i need ?

all i need is if the source ip was from subnet ip 192.168.10.0/24 i want to send it to socks 1

if source ip was from ip 192.168.20.0/24 i want it to go to socks 2

=============
here is my config
=================
root@VPNSOCKS:~# /etc/init.d/redsocks restart
* Restarting redsocks redsocks
...done.
root@VPNSOCKS:~#
========================
root@VPNSOCKS:~# /etc/init.d/redsocks restart
* Restarting redsocks redsocks
...done.
root@VPNSOCKS:~# cat /etc/redsocks.conf
base {
// debug: connection progress & client list on SIGUSR1
//log_debug = off;
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 = "syslog:daemon";
log = "file:/var/log/redsocks";
// detach from console
daemon = on;

/* 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 = redsocks;
group = redsocks;
// 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 127.0.0.1 for security reasons,
* use 0.0.0.0 if you want to listen on every interface.
* `local_*' are used as port to redirect to.
*/
local_ip = xx.231.2;
local_port = 12345;

// `ip' and `port' are IP and tcp-port of proxy-server
// You can also use hostname instead of IP, only one (random)
// address of multihomed host will be used.
ip =xx.66.10;
port = 1221;


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

// login = "foobar";
// password = "baz";
}
//////////////////////////////////
redsocks {
/* `local_ip' defaults to 127.0.0.1 for security reasons,
* use 0.0.0.0 if you want to listen on every interface.
* `local_*' are used as port to redirect to.
*/
local_ip = xxx.231.2;
local_port = 12346;

// `ip' and `port' are IP and tcp-port of proxy-server
// You can also use hostname instead of IP, only one (random)
// address of multihomed host will be used.
ip = xxx.66.11;
port = 1221;


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

// login = "foobar";
// password = "baz";
}
redudp {
// `local_ip' should not be 0.0.0.0 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 = 127.0.0.1;
local_port = 10053;

// `ip' and `port' of socks5 proxy server.
ip = 192.0.2.1;
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 127.45.67.89 if you need more than 65535 ports to
// forward ;-)
// This limitation may be relaxed in future versions using contrack-tools.
dest_ip = 192.0.2.2;
dest_port = 53;

udp_timeout = 30;
udp_timeout_stream = 180;
}

dnstc {
// fake and really dumb DNS server that returns "truncated answer" to
// every query via UDP, RFC-compliant resolver should repeat same query
// via TCP in this case.
local_ip = 127.0.0.1;
local_port = 5300;
}

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

================
iptables rules :
=========
sudo iptables -t nat -N REDSOCKS

sudo iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN
sudo iptables -t nat -A REDSOCKS -p tcp -s 192.168.10.0/24 --dport 80 -j REDIRECT --to-ports 12345
sudo iptables -t nat -A REDSOCKS -p tcp -s 192.168.20.0/24 --dport 80 -j REDIRECT --to-ports 12346
sudo iptables -t nat -A OUTPUT -p tcp -o eth0 -j REDSOCKS

==============

with the config above , it dont work and i cant tunnel tcp tunnel http traffic to the 2 socks servers i have !!! ??
i want to know what i need to do ?

CROSP
Posts: 4
Joined: 2017/04/06 20:53:26

Re: redsocks help as socks redirector

Postby CROSP » 2017/07/15 09:32:51

I have written an article describing the process of installing and configuring Redsocks on Centos.
Here it is https://crosp.net/blog/administration/i ... tos-linux/

If you have any problems, feel free to ask me