LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 07-31-2008, 03:13 AM   #1
pooppp
Member
 
Registered: May 2008
Posts: 32

Rep: Reputation: 15
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
 
Old 07-31-2008, 10:19 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Destination HOST Unreachable - cannot ping gateway rpkosuri Linux - Networking 5 06-16-2008 11:38 PM
when ping I get Destination host unreachable Fuzia Linux - Networking 1 06-19-2006 01:22 AM
windows 98 m/c ping to ip address of red hat server but fails to ping hostname ravilohot Linux - Networking 2 09-07-2004 04:57 AM
Shell script ip address format check. rooch84 Linux - Software 6 08-18-2004 09:14 AM
problem to print source address and destination address jooboo Programming 2 11-26-2003 03:24 PM


All times are GMT -5. The time now is 03:39 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration