linux 配置物理机和虚拟机使用代理访问网络

linux 通过ssr代理连接网络

1.物理机

1.首先ssr软件正常使用
2.配置ssr地址为0.0.0.0或者127.0.0.1
3.安装privoxy

privoxy的作用是将socks5转化为http/https
yum install -y epel-release
yum install -y privoxy

4.编辑privoxy的配置文件/etc/privoxy/config

user-manual /usr/share/doc/privoxy/user-manual
confdir /etc/privoxy
logdir /var/log/privoxy
actionsfile match-all.action # Actions that are applied to all sites and maybe overruled later on.
actionsfile default.action   # Main actions file
actionsfile user.action      # User customizations
filterfile default.filter
filterfile user.filter      # User customizations
logfile logfile
listen-address  127.0.0.1:8118
listen-address  [::1]:8118
forward-socks5 / 127.0.0.1:1080 .
toggle  1
enable-remote-toggle  0
enable-remote-http-toggle  0
enable-edit-actions 0
enforce-blocks 0
buffer-limit 4096
enable-proxy-authentication-forwarding 0
forwarded-connect-retries  0
accept-intercepted-requests 0
allow-cgi-request-crunching 0
split-large-forms 0
keep-alive-timeout 5
tolerate-pipelining 1
socket-timeout 300

5.编辑.bashrc/.zshrc文件增加以下配置

export http_proxy="127.0.0.1:8118"
export https_proxy="127.0.0.1:8118"
export ftp_proxy="127.0.0.1:8118"

6.启动privoxy

systemctl start privoxy
systemctl enable privoxy

7.测试

curl ipinfo.io
curl www.google.com

8.注意此方式可以实现终端代理,但是浏览器代理请使用浏览器插件

2.虚拟机

1.首先保证宿主机代理正常工作

2.ifconfig查看宿主机内网ip

3.设置ssr代理地址为0.0.0.0而非127.0.0.1

4.虚拟机执行telnet 宿主机内网ip:1080 看是否可连接,如果可以进行下一步操作

5.安装privoxy,并将config文件配置为

yum install -y epel-release
yum install -y privoxy
user-manual /usr/share/doc/privoxy/user-manual
confdir /etc/privoxy
logdir /var/log/privoxy
actionsfile match-all.action # Actions that are applied to all sites and maybe overruled later on.
actionsfile default.action   # Main actions file
actionsfile user.action      # User customizations
filterfile default.filter
filterfile user.filter      # User customizations
logfile logfile
listen-address  127.0.0.1:8118
listen-address  [::1]:8118
forward-socks5 / 192.168.100.27(宿主机ip):1080 .
toggle  1
enable-remote-toggle  0
enable-remote-http-toggle  0
enable-edit-actions 0
enforce-blocks 0
buffer-limit 4096
enable-proxy-authentication-forwarding 0
forwarded-connect-retries  0
accept-intercepted-requests 0
allow-cgi-request-crunching 0
split-large-forms 0
keep-alive-timeout 5
tolerate-pipelining 1
socket-timeout 300

6.增加/etc/profile.d/proxy.sh文件

export ALL_PROXY=http://127.0.0.1:8118

7.刷新环境变量

source /etc/profile.d/proxy.sh

8.启动privoxy

source /etc/profile.d/proxy.sh

9.测试

curl ipinfo.io
curl www.google.com

猜你喜欢

转载自www.cnblogs.com/limengchun/p/12586106.html