前書き
俗にいう串が欲しかったもののhttp proxyサーバを立てるだけでは芸がないので、socksサーバを立てた。
ネットでは、内部のネットワークから外のインターネットに接続する際に用いる使い方の記事が多いが、本記事では「発信元IPを偽装する」ような使い方をするための設定を記載する。
なお、socksサーバはプロトコルを考慮せずともすべてプロキシ経由にできることがhttp proxyサーバとの最も大きな違い。
環境
[puri@banana ~]$ cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
インストール方法
CentOSでSOCKSサーバ(Dante)を構築するを参考にインストール
設定
- clientなんちゃらはsocksサーバに接続する際に適用される設定項目
- socksなんちゃらはsocksサーバで認証された後に適用される設定項目
公式ドキュメントを確認のこと
sockd.conf
internal: eth0 port = xxxx
# 認証方法 (passwdを用いた認証。平文でパスワードが送信されることに注意)
socksmethod: username
clientmethod: none
# passさせるクライアントの設定。
# ここではIP制限は設けていない
client pass {
from: 0.0.0.0/0 port 1-65535 to: 0.0.0.0/0
clientmethod: none # match all idented users that also are in passwordfile
socksmethod: username
}
# ローカルへのアクセスをブロック
socks block {
from: 0.0.0.0/0 to: lo0
log: connect error
}
socks pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
command: bind connect udpassociate
log: error
socksmethod: username
clientmethod: none
protocol: tcp udp
}
ポート開放
sudo firewall-cmd --add-port=xxx/tcp --permanent
sudo firewall-cmd --reload
起動
sudo systemctl start sockd
起動確認
Firefox + FoxyProxyで確認する
認証付きsocks5サーバはFx単体でアクセスできないことに注意
発信IPがsocksサーバのものになっていることを確認する