
您有什麼解決方案可以讓我獲得從伺服器下載或上傳到 TCP 或 UDP 協定上的伺服器的速度,而我無權存取該伺服器?但我有我的伺服器的根訪問權限。
例如,我有一台伺服器,但無法存取Google伺服器來安裝特殊程序,只有該外部伺服器的網站位址或IP,我想知道我的伺服器和該Google伺服器之間的資料傳輸速度? (類似下載/上傳檔案)
我最好的選擇是 Linux CLI 平台,任何想法、解決方案、開源程式碼、程式或任何解決方案或建議都是有幫助的。
答案1
我假設您有 nftables 或 iptables 可用。以下命令適用於 iptables。
iptables -N ACCT_OUT #outbound accounting
iptables -n ACCT_IN #inbound accounting
iptables -A FORWARDING --dst <remoteip> -j ACCT_OUT
iptables -A FORWARDING --src <remoteip> -j ACCT_IN
iptables -A ACCT_IN -p tcp
iptables -A ACCT_IN -p udp
iptables -A ACCT_IN -p icmp
iptables -A ACCT_OUT -p tcp
iptables -A ACCT_OUT -p udp
iptables -A ACCT_OUT -p icmp
這將計算命中這些鏈的位元組數。
iptables -L -n -v -x
這會將計數器清零。
iptables -Z ACCT_OUT
iptables -Z ACCT_IN
該資源提供了更詳細的答案。 https://catonmat.net/traffic-accounting-with-iptables