title: How to determine the subnet mask and network interface card from remote SSH login?
body: <p>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. </p>
  
  <p>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. </p>
  
  <p>Thanks for any help you can provide! </p>
  
  <p><a href="https://stackoverflow.com/questions/30244608/how-to-return-from-shell-read-command-passed-in-expect-script?noredirect=1#comment48592789_30244608">How to return from shell &#39;read&#39; command passed in expect script?</a></p>
  
  <p><strong>--UPDATE--</strong></p>
  
  <p>AIX ifconfig -a:</p>
  
  <pre><code>$ ifconfig -a
  en0: flags=1e080863,480&lt;UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPR
  T,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN&gt;
          inet 10.105.65.131 netmask 0xffff0000 broadcast 10.105.255.255
           tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
  lo0: flags=e08084b,c0&lt;UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64
  BIT,LARGESEND,CHAIN&gt;
          inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
          inet6 ::1%1/0
           tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1
  </code></pre>
  
  <p>AIX netstat -rn:</p>
  
  <pre><code>$ 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      -      -   =
  &gt;
  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      -      -
  </code></pre>
  
  <p>I tried <code>route get</code> 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 <code>ip route</code> that would work. </p>
  
  <p>The Linux boxes support both <code>ip</code> and <code>ifconfig</code>. </p>
  
  <p>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.  </p>
  
  <p>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. </p>