unbuntu命令行使用socks代理

目前國內gfw越來越嚴格的形勢下, 翻q最穩定的還是socks協議了,然而在ubuntu下,一般用代理的地方是瀏覽器,但有時候命令行中也需要連google服務器.但ubuntu下我沒找到能設置全局socks代理的地方,就想着怎麼單獨解決命令行下使用socks代理的問題.後來發現了一個命令socksify,有同樣問題的可以試試.


  • 安裝

    sudo apt-get install dante-client

  • 配置 /etc/dante.conf , 主要是下面這段去掉註釋改一下

# IP address 10.1.1.1, port 1080.   Note that unless you have
# specified a direct connection for DNS, or the socksserver is resolvable
# without network traffic, you can't give a hostname for the socksserver,
# you must give a IP address.  (the reasons for that are logical enough,
# you would create a loop otherwise.)
route {
    from: 0.0.0.0/0   to: 0.0.0.0/0   via: 127.0.0.1 port = 1080
    protocol: tcp udp                # server supports tcp and udp.
    proxyprotocol: socks_v4 socks_v5 # server supports socks v4 and v5.
    method: none #username       # we are willing to authenticate via
                     # method "none", not "username".
}
  • 配置~/.ssh/config

Host lxxxxxw.com #這裏和下一行換成自己vps的域名和ip
Hostname 131.122.221.226
Compression yes
ConnectTimeout 10
DynamicForward 127.0.0.1:1080

+ 使用,和sudo類似的用法,在要用的命令前加socksify就行,(當然,本地用來連接遠程的代理得先打開哦)比如
socksify curl https://twitter.com/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章