Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

arping Error { bind: Cannot assign requested address } when trying to run it remotely

Tags:

sh

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?

like image 783
Muthu Avatar asked Jan 19 '26 17:01

Muthu


1 Answers

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.

like image 99
LMC Avatar answered Jan 21 '26 08:01

LMC