In a separate question (link below), it was suggested that I obtain the network interface card number and subnet mask from a remote SSH login, rather than prompting the user for it. All I have is the IP address of my remote host. I need to obtain the subnet mask to determine if the remote and local host are on the same subnet, and the interface card number to set up and configure a virtual IP for aliasing purposes.
Could someone suggest how I might be able to parse out the necessary information and return it to my shell script that initiates the remote ssh connection? My target hosts have Linux or AIX as the operating system. I am familiar with the netstat function, but I'm not sure if parsing information from this is valid, or if there is a better way to get what I need that will work for both Linux and AIX operating systems.
Thanks for any help you can provide!
AIX ifconfig -a:
$ ifconfig -a en0: flags=1e080863,480<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPR T,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN> inet 10.105.65.131 netmask 0xffff0000 broadcast 10.105.255.255 tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1 lo0: flags=e08084b,c0<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64 BIT,LARGESEND,CHAIN> inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255 inet6 ::1%1/0 tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1
AIX netstat -rn:
$ netstat -rn Routing tables Destination Gateway Flags Refs Use If Exp Groups Route tree for Protocol Family 2 (Internet): default 10.105.65.1 UG 31 39412125 en0 - - 10.105.0.0 10.105.65.131 UHSb 0 0 en0 - - = > 10.105/16 10.105.65.131 U 219 985607244 en0 - - 10.105.65.131 127.0.0.1 UGHS 5 1326738 lo0 - - 10.105.255.255 10.105.65.131 UHSb 3 6926640 en0 - - 127/8 127.0.0.1 U 36 11962928 lo0 - - Route tree for Protocol Family 24 (Internet v6): ::1%1 ::1%1 UH 1 393270 lo0 - -
route get and that doesn't work on my AIX box to tell me the route. The only thing I can get to work is netstat -rn. I'm not sure if there is another command similar to
ip route that would work.
The Linux boxes support both
I am not sure what to do when there are multiple network interface cards, as I do not know which one really should be used when setting up a virtual IP.
The Linux setup is more what I am concerned with, as I will be eventually adding in the AIX support for my software installation script later and can do more research on it then.