如何限制只能透過一個主機名稱存取socks5伺服器?

如何限制只能透過一個主機名稱存取socks5伺服器?

我有一個dante 伺服器ocks5代理) 指向我的主機名稱之一 ( sub.example.com)。這是我的基本配置(我自己的網域替換為範例變體):

logoutput: /var/log/danted.log

internal: sub.example.com port = 9000
external: sub.example.com

user.privileged: root
user.notprivileged: nobody

socksmethod: username

client pass {
    from: 0/0 to: sub.example.com
    log: error connect disconnect
}

socks pass {
    from: 0/0 to: sub.example.com
    command: bind connect udpassociate
    log: error # connect disconnect
}

socks pass {
    from: 0/0 to: sub.example.com
    command: bindreply udpreply
    log: error # connect disconnect
}

# Even blocked the main hostname, also tried ".example.com",
# with libwrap compiled and activated (and "hosts.access" too)

socks block {
    from: 0/0 to: example.com
    log: error connect disconnect
}

我只想將代理連接限制為sub.example.com,但我仍然可以透過其他子網域和 進行連接example.com。是否可以限制只有一個主機名稱?

答案1

找到了解決方法,但這是一個不好的做法。因為我使用的是 DigitalOcean,所以它們為每個伺服器提供浮動 IP。我啟動了它並執行了一些操作以將流量轉送到實際的浮動 IP。

根據這篇文章如何在 DigitalOcean 上使用浮動 IP您必須先接收本機 IP 才能使用浮動 IP 執行操作。

  1. 輸入curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/anchor_ipv4/address您的伺服器並記住收到的 IP 位址。
  2. 編輯文件中的internalexternal如果需要)欄位danted.conf以符合接收到的 IP。
  3. 重新啟動伺服器。

現在一切正常,只是浮動 IP 還沒有 IPv6。

相關內容