Curl
使用自定義 IP 發送 CURL 請求
難道不應該嗎?假設我不需要響應,我只想發送請求。我們不應該能夠更改 tcp/ip 標頭,因為我們的電腦會發送它嗎?我可能錯過了一些東西,只是真的很好奇,在大學裡學習它。
您可以使用以下
-H/--header
參數:你可以欺騙你的IP地址:
curl --header "X-Forwarded-For: 192.168.0.2" http://example.com
範例:
客戶端
$ curl http://webhost.co.uk
網路主機
$ tailf access.log | grep 192.168.0.54 192.168.0.54 - - [10/Nov/2014:15:56:09 +0000] "GET / HTTP/1.1" 200 14328 "-" "curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2"
更改 IP 地址的客戶端
$ curl --header "X-Forwarded-For: 192.168.0.99" http://webhost.co.uk
網路主機
$ tailf access.log | grep 192.168.0.99 192.168.0.99 - - [10/Nov/2014:15:56:43 +0000] "GET / HTTP/1.1" 200 14328 "-" "curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2"
男人捲曲
-H/--header <header> (HTTP) Extra header to use when getting a web page. You may specify any number of extra headers. Note that if you should add a custom header that has the same name as one of the internal ones curl would use, your externally set header will be used instead of the internal one. This allows you to make even trickier stuff than curl would normally do. You should not replace internally set headers without knowing perfectly well what you’re doing. Remove an internal header by giving a replacement without content on the right side of the colon, as in: -H "Host:".
參考: