LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Script for IFCONFIG tht PING with destination ip address in same format (http://www.linuxquestions.org/questions/linux-networking-3/script-for-ifconfig-tht-ping-with-destination-ip-address-in-same-format-659437/)

pooppp 07-31-2008 03:13 AM

Script for IFCONFIG tht PING with destination ip address in same format
 
I want a script that should ping with the same ip address format in kernel.

Unix Shell script needed for below ques:
insmod ./xge.ko
ifconfig ethxxx 1.1.1.1 up
ifconfig ethxxx down
rmmod xge

src
ifconfig eth2 2.2.2.4 up
ping 2.2.2.5

dst
ifconfig eth3 3.3.3.4 up
ping 3.3.3.5

In above, if the second parameter of ifconfig is eth2 & corresponding ip is 2.2.2.4 it should ping with 2.2.2.5 like tht...I need script for tht...Plz help me

theNbomr 07-31-2008 10:19 AM

The essence of your problem is to compose two IPs in which the second differs from the first in the last octet, and the last octet is one greater than the last octet of the first. So:
Code:

octet321="4.4.4."
octet0="4"
octet0plus=`expr $octet0 + 1`
ip1=$octet321$octet0
ip2=$octet321$octet0plus
echo $ip1
echo $ip2

ifconfig eth4 $ip1 up
ping $ip2

--- rod.


All times are GMT -5. The time now is 08:43 PM.