Local Server : Lets say local1 Remote Server: Lets say remote1
I have the following shell script in local1 server;
#!/bin/sh
comm1=`arping -c 3 -s 192.168.xxx.xx 192.168.yyy.yy | grep "reply from 192.168.yyy.yy" | awk '{print $2,$3,$4}' | tail -1 | awk '{print $3}'`
comm2="192.168.yyy.yy"
if [[ "$comm1" == *"$comm2"* ]]
then
echo "IP is up and running fine"
else
echo "IP is not up and running"
fi
If I run the above script in local server, I am getting the desired output, which is "IP is up and running fine".
But if I copy the same script to remote1 server and try to execute from remote1 server against local1 server, it is executing the script but giving the following output;
bind: Cannot assign requested address
IP is not up and running
So, remote1 server is able to execute the script on local1 server, but it is skipping the true condition with error as I mentioned above.
FYI, I ran the following command on remote1 server;
ssh [email protected] /root/script.sh
Any idea where Iam going wrong or how to overcome this error?
For the remote server you have to switch IPs
arping -c 3 -s 192.168.yyy.yy 192.168.xxx.xx
The server IP ends with yyy.yy but you are trying to use xxx.xx as the source IP for the command (-s) which is denied by the remote OS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With