how to Using bash to generate random IPs in Curl
You're quoting incorrectly. You can try:
curl --header "X-Forwarded-For: $(printf "%d.%d.%d.%d" "$((RANDOM % 256))" "$((RANDOM % 256))" "$((RANDOM % 256))" "$((RANDOM % 256))")"
You can get rid of the inner quotes and even the printf
entirely:
curl --header "X-Forwarded-for: $((RANDOM % 256)).$((RANDOM % 256)).$((RANDOM % 256)).$((RANDOM % 256))"
However, whether the target site accepts the X-Forwarded-For
is another matter entirely. Setting this header does not actually hide your own IP from the target site.
I will suggest this design
shuf -i 0-255 -rn4 | paste -sd.
But it loses printf
since the first value in IP should not be equal to 0
printf %d.%d.%d.%d $((RANDOM%255+1)) $((RANDOM%256)){,,}
First the shell opens the "Brace Extension" and then substitutes the values of the variables