Redirect all local traffic to shadow-socks proxy
Iptables reroute to shadowsocks
I have ubuntu 20.04 vps with shadow-socks server on it.
I also have ubuntu 20.04 on my pc, with shadow-socks client running on it. Currently using shadow-socks-libev version.
The goal is to redirect all requests to 127.0.0.1:1080, where proxy client is running.
However, nothing made it work for me.
Steps I made
I. I created admin user for running shadow socks client only.
II. I made systemd unit to start client on boot from separate user, content of file listed below:
[Unit] Description=SahdowSocks After=network.target After=network-online.target [Service] ExecStart=ss-local -c /etc/shadowsocks-client/config.json Restart=on-failure User=socks_user Group=socks_user [Install] WantedBy=multi-user.target
At this point if I'm setting 127.0.0.1:1080 in my browser (firefox) as a socks5 proxy - it works fine.
III. Then I made iptables rules, according to the links above.
sudo iptables -t nat -A OUTPUT -p tcp -m owner ! --uid-owner socks_user --dport 80 -j REDIRECT --to-port 1080 sudo iptables -t nat -A OUTPUT -p tcp -m owner ! --uid-owner socks_user --dport 443 -j REDIRECT --to-port 1080
After that, I can still use the browser if connected directly to the proxy through settings, but after switching to no proxy/system proxy - getting request timeout. All other apps also have no connection.
?*?J?u?s?t? ?t?o? ?m?e?n?t?i?o?n?,? ?i?f? ?I? ?d?o? ?p?i?n?g? ?t?o? ?1?.?1?.?1?.?1? ?i?t? ?r?e?t?u?r?n?s? ?f?i?n?e? (Got answer in the comments.)
*If I do wget http://someurl it ends with no result.
So I assume I'm getting reroute loop (?), but don't understand why.