How to extract NIC and other info ,given Ip

Hi all,

I am working on a networking project that requires me to find out the NIC on that particular machine and many more things.
Now Given the IP and the subnet.
I would like to know how we can extract such informations?
I am talking in exclusivity to Solaris boxes!!
The required permissions are all granted!

Pls assist!

Hiii...
You can use ifconfig -a , dladm show-dev , dladm show-link comands....

Cheers....

hey ,
I know about those commands.
In fact am implementing all these in a slightly different way :slight_smile:
The point am trying to make here is.
how do i get the dladm commands to work remotely?
If suppose i know the IP of some machine, how do i hook onto it and use the dladm cmds to extract these details!

thanks

Consider using Expect - it's invaluable tool for network / system administration and automation. Else, do an SSH shot as in : ssh root@server "command to execute"

This is the first time I will be using ssh.
So could you please elaborate on root@server ?
Thanks

Executing commands remotely via SSH isn't that much different from doing the same via rsh/remsh, except for the lack of the cryptographic tunnel, so to speak.
Usually one would create a pair of RSA keys by ssh's ssh-keygen command,
then distribute it to all remote hosts where one wishes to remotely execute the commands.
On the host from where you schedule your checks create a key pair.
Log in as a non-root user.
If in your $HOME there is no subdir .ssh present then it would be the easiest way to create the necessary structure by connecting to any remote SSH server. This doesn't have to be a real login. You would only confirm with yes when you are asked by your ssh client if it should add the new host key from the remote host. Then interrupt by pressing ^C.
This only serves the purpose to have the .ssh subdir and known_hosts file in it automatically created with the correct ownership and permission bits by your SSH client
because per default any SSH server runs with StrictModes enabled and thus is very picky about correct perms.
So run $ ssh some_host, confirm with yes, and abort when being asked for a password.
Now you can create your RSA key pair by issuing

 $ ssh-keygen -t rsa -b 1024 -N "" -f ~/.ssh/id_rsa

Note, that I above explicitly provided the new private RSA key with an empty passphrase
which basically is from the security standpoint a pretty poor choice.
A better solution would be to omit the -N switch and enter a passphrase,
then start the ssh-agent and ssh-add your key.
But this would at least once require interactive user input.
Now you need to distribute your new public RSA key to any remote host where you want to run commands on.
This requires that you can login there (i.e. know some user/passwd),
and that this user also already has a correctly set up $HOME/.ssh directory.
If this is the case you can next scp the key in the proper place by issuing

$ ssh remuser@remhost 'cat >>.ssh/authorized_keys' < ~/.ssh/id_rsa.pub

If all went well you are now ready to run commands remotely that you could schedule by cron.
e.g.

$ ssh -i ~/.ssh/id_rsa -l remuser remhost /usr/sbin/ifconfig -a

or any other command that remuser has permissions to execute on remhost.
You can pipe its output into grep locally (just append "| grep whatever"),
or do the parsing also remotely.
In that case you need to quote the pipe by prepending a backslash
(in fact any meta character that your local shell would otherwise interpret).

Ok thats really helpful.
Thanks for all your replies!
I will implement it and let you know

Thanks again!