AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
 View Only
  • 1.  How Do I Compare ODM with the Current Routing Table?

    Posted Thu May 14, 2015 01:35 PM

    Originally posted by: JeffPrince


    I'm new to AIX, but not to UNIX in general. My Solaris and IRIX get rustier with each passing day. I've been mainly using RHEL for the last several years.  Now, I use both AIX 6.1 and 7.1.

    My task it to write a shell script that compares the current routing table, from netstat -rn, with the ODM. There have been occasions where a new route was manually added, but not to the ODM. Weeks later the system is rebooted and the required route is missing. I want to periodically and automatically (think cron) run my script and report if there is a difference.

    Is there an existing AIX tool to do this non-interactively, a smitty command perhaps? I'd love to use it. If not, how does AIX build the routing table at boot time? Can I examine that process to discover how it works?

    Since the system has to read the ODM to build the routing table, I am considering using the output of  lsattr -El inet0 -a route -F value or odmget -q "name=inet0" CuAt to build my own table and compare with the current routing table, but I do not know how to properly parse the output from those two commands. (Or even if those commands are complete enough to build all the routes.) I found chginet Method which states the value of the route attribute is

    route = type, [args,], destination, gateway, [metric]

    I do not understand how this describes output such as mine below. (I've changed the IPs, but not the other values. Remember I just want to understand the layout of the data and how it builds a routing table, not to verify correctness.)  And compare it with the active routing table.

    net,-hopcount,0,,0,10.20.225.1

    net,,0,10.22.226.1

    host,-hopcount,0,,-if,en1,,,,-static,172.16.25.40,10.22.160.1 

    net,10.20.226.0,-netmask,255.255.254.0,10.20.225.1
    net,-hopcount,0,-netmask,255.255.255.0,,,,,-static,10.0.1.0,10.22.160.1
    net,-hopcount,0,-netmask,255.255.255.0,-if,en1,,,,-static,10.0.5.0,10.22.160.1
    net,-hopcount,0,-netmask,255.255.192.0,,,,,10.22.125.0,10.22.160.1

    net,-hopcount,0,-netmask,255.255.255.0,,,10.19.215.0,10.22.160.1

     

    It is obvious that type = net|host but then how do I determine when the [args,], ends and destination begins? If I should be looking for ,, I've got way too many commas.  Do I just need to count from the ends and assume the middle is all [args,],?   What are the valid values and their dependencies in [args,],?  So. . .

    Does someone have an explanation that goes into more detail than the link at chginet Method?  Perhaps a link to a detailed document?  

    If I'm following the wrong path to solve my task, please point me in the right direction. I am not looking for someone to write the code for me.  (But if a tool that does this exists, I'll use it!)  I am pretty darn good with the Bourne and Korn shells. My AIX systems do not have BASH installed.  I just need an understanding of what to look for and how to interpret it.  I need to report on differences between the ODM and routing table, I do not need to add or delete routes.


    #AIX-Forum


  • 2.  Re: How Do I Compare ODM with the Current Routing Table?

    Posted Thu May 14, 2015 04:54 PM

    Originally posted by: DaveMarquardt


    I'm not aware of any command that does what you're trying to do.  That's kind of surprising, as it seems like an obvious thing to do!

    The route data in inet0 is what you would pass to route add to recreate the route.  Syntax, from the route man page, is

    Syntax

           route [ -f ] [ -n ] [ -q ] [ -C  ] [ -v ] Command [ Family ] [ [ -net | -host ] Destination [
           -prefixlen  n] [ -netmask  [ Address ] ] Gateway ] [ Arguments ] [- i] [-@ WparName]

     

    Parsing this is context specific.  So, with the first line you showed, it becomes

    route add net -hopcount 0 0 10.20.225.1

    -hopcount requires an argument, which is the first 0.  The next 0 then is the destination.  0?  That stands for the default route.  Then the gateway is 10.20.225.1.

    Does this help?


    #AIX-Forum


  • 3.  Re: How Do I Compare ODM with the Current Routing Table?

    Posted Thu May 14, 2015 05:07 PM

    Originally posted by: JeffPrince


    It certainly does help.  Thank you very much!  Let me work on that for a day or two. 

    Do you know if there is a such thing as inet1 or inet2, or is there only an inet0?  I have not seen anything but inet0.


    #AIX-Forum


  • 4.  Re: How Do I Compare ODM with the Current Routing Table?

    Posted Thu May 14, 2015 05:48 PM

    Originally posted by: DaveMarquardt


    There's only inet0.  It's the object related to configure the netinet kernel extension, and only 1 such object is expected to exist.

    BTW,, there can also be rout6 attributes for IPv6 routes.


    #AIX-Forum


  • 5.  Re: How Do I Compare ODM with the Current Routing Table?

    Posted Thu May 14, 2015 05:50 PM

    Originally posted by: The_Doctor


    I think you're on the right track.  AFAIK, there is only ever an "inet0".

     

    To help you understand the args, this might help (or just frustrate you :))....... have a look at smitty, ADD STATIC ROUTE (shortcut is "smitty mkroute").

    Then modify each option you're interested in..... and press F6, to see the script that gets run when that option is selected.  Sorta long, roundabout way to get to see each arg that can be passed...... but you do what you have to.

     

    Now if you only had a BFH to beat on the guy/gal that manually runs the "route" command rather than using the "chdev -l inet0........ (via smitty if necessary)" :)

     

     


    #AIX-Forum


  • 6.  Re: How Do I Compare ODM with the Current Routing Table?

    Posted Fri May 15, 2015 10:34 AM

    Originally posted by: JeffPrince


    I just received this suggestion from IBM support, minus the part about modifying each option.  Thanks for adding that and the BFH suggestion!


    #AIX-Forum