使用Proxychains强制terminal命令行走代理的配置过程

  1. 安装Proxychains

    $ git clone https://github.com/rofl0r/proxychains-ng.git
    $ cd proxychains-ng
    $ ./configure --prefix=/usr --sysconfdir=/etc
    
    以下用于编译和安装conf文件,需要gcc环境
    $ sudo make -j8 
    $ sudo make install
    $ sudo make install-config
    

    PS:MacOS可以使用brew直接安装

    ​ Mac使用前需要关闭SIP,自行衡量利弊

  2. 修改配置文件

    $ sudo gedit /etc/proxychains.conf
    
    #将最后一行的
    #socks4 127.0.0.1 9095
    #修改为
    #socks5 127.0.0.1 1080
    #其中1080为本地sock5代理端口,在相关上网软件中配置为自己的端口号即可
    
  3. 别名设置

    为了方便测试网络情况,设置相关alias

    $ gedit ~/.zshrc
    
    #末尾追加以下语句
    alias fq=proxychains4
    alias iptest='curl cip.cc'
    alias fqtest='proxychains4 curl cip.cc'
    
    $ source ~/.zshrc
    
  4. 使用方法

    • iptest测试本机ip

    • fqtest测试代理上网后的ip

    • 其他需要使用代理的命令行,在使用前加上proxychains4fq即可

  5. 测试当前终端是否走代理的方法

    • 可以使用$ curl cip.cc
    • 可以使用$ wget google.com
    • 不可以使用$ ping google.com(一个很常见的误区)
posted @ 2020-07-09 20:16  Tzbubble  阅读(681)  评论(0编辑  收藏  举报