Operating System - HP-UX
1823063 Members
3237 Online
109645 Solutions
New Discussion юеВ

how do you figure out the IP index # on the same lan?

 
SOLVED
Go to solution
cgzou
Occasional Advisor

how do you figure out the IP index # on the same lan?

Hi,
for example, I have two IP address assigned to the same lan card using ifconfig, now programing wise how do I know what is the remainning IP index I can use to add another IP adddress to the same lan card?

Thanks in advance!
8 REPLIES 8
Jeff Schussele
Honored Contributor
Solution

Re: how do you figure out the IP index # on the same lan?

Hi,

You could do the following

netstat -in | grep lanX | awk '{print $1}'

where X = lan instance
This will give all the lan assignments on it in use.

Should get something like

lan0
lan0:1
lan0:2

Therefore the next available is lan0:3

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Michael Steele_2
Honored Contributor

Re: how do you figure out the IP index # on the same lan?

Can't your refer to the network ip?

netstat -rn

What's in /etc/rc.config.d/netconf? Here's an example:

INTERFACE_NAME[0]=lan0:0

IP_ADDRESS[0]=X.X.X.X

INTERFACE_NAME[1]=lan0:1

IP_ADDRESS[1]=X.X.X.X
Support Fatherhood - Stop Family Law
cgzou
Occasional Advisor

Re: how do you figure out the IP index # on the same lan?

Jeff,
That is exactly what I want. You got the points.

Thanks
Sridhar Bhaskarla
Honored Contributor

Re: how do you figure out the IP index # on the same lan?

Hi,

The following shell may help you.


#!/usr/bin/ksh
for lan in $(netstat -in |grep -v ":"|grep -v "\*" |awk '/lan/ {print $1}')

do
LAST=$(netstat -in |grep ${lan}: |sort|tail -1 |awk '{print $1}'|awk '{FS=":";pr
int $2}')
if [ $LAST ]
then
(( NEXT= $LAST + 1 ))
echo "${lan}:${NEXT} is next for $lan"

else
echo "${lan}:0 is next for $lan"
fi
done

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
cgzou
Occasional Advisor

Re: how do you figure out the IP index # on the same lan?

Thank you all for the quick and helpful reply. Do you know how to assign the points to each of you? or somebody else will do it?


Thanks again.
Jeff Schussele
Honored Contributor

Re: how do you figure out the IP index # on the same lan?

Hi,

At the top of all reply posts you'll see a drop-down box.
You drop it down and select the value.

Then click the Submit button at the bottom & it should assign them.
Lately though, some have reported that they have to do this twice. So just check it after you submit to see if it shows points.

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Patrick Wallek
Honored Contributor

Re: how do you figure out the IP index # on the same lan?

First you must be logged in to assign points. If you are posting, then you are already logged in.

To assign points, click on the down arrow next to the date/time of the reply and select the # of points you want to give each reply (between 0 & 10 for each reply) then click on the SUBMIT button at the bottom left of the last reply.

You should be done. If you notice that points haven't been assigned after you click submit and go back to the message, you may have to do it again. If you are one of us that uses Opera 7.0X, then there is a problem with Opera and you have to open a differnet browser to get it to work.
Sridhar Bhaskarla
Honored Contributor

Re: how do you figure out the IP index # on the same lan?

hmmm.. OK. When you said programming wise I thought you were asking for a script.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try