Menu

n_host Hostnames truncating in neighbor table

Help
2014-12-19
2015-02-03
  • Ryan Mahoney

    Ryan Mahoney - 2014-12-19

    Jonathan - I have been enjoying the features of NetDB a couple years now. I really appreciate the effort you've put into keeping this project active. I recently became aware that devices with an underscore in the hostname are getting truncated in the neighbor table. I am aware that underscore characters are not a good idea because of DNS limitations... however an outside vendor deployed hundreds of wireless access points in my environment and used this character in the hostnames. Here is an example cdp neighbor lookup in a Cisco CLI:
    s1-sfmh-68-09-2#show cdp neighbors
    Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
    S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone

    Device ID Local Intrfce Holdtme Capability Platform Port ID
    s1-sfmh-core
    Gig 0/51 134 R S I WS-C6513 Gig 9/19
    AP2-68_09_2-MAIN-SFMH
    Gig 0/13 166 T AIR-CAP350Gig 0
    AP8-68_09_2-MAIN-SFMH
    Gig 0/29 144 T AIR-CAP350Gig 0
    AP3-68_09_2-MAIN-SFMH
    Gig 0/14 166 T AIR-CAP350Gig 0
    AP9-68_09_2-MAIN-SFMH
    Gig 0/30 148 T AIR-CAP350Gig 0
    AP1-68_09_2-MAIN-SFMH
    Gig 0/12 130 T AIR-CAP350Gig 0
    AP6-68_09_2-MAIN-SFMH
    Gig 0/26 149 T AIR-CAP350Gig 0
    AP7-68_09_2-MAIN-SFMH
    Gig 0/28 133 T AIR-CAP350Gig 0
    AP4-68_09_2-MAIN-SFMH
    Gig 0/15 129 T AIR-CAP350Gig 0
    AP5-68_09_2-MAIN-SFMH
    Gig 0/16 147 T AIR-CAP350Gig 0
    s2-sfmh-68-09-2 Gig 0/52 149 S I WS-C3560G-Gig 0/51
    WIP1-68_09_2-MAIN-SFMH
    Gig 0/31 139 T AIR-CAP350Gig 0
    WIP2-68_09_2-MAIN-SFMH
    Gig 0/32 173 T AIR-CAP350Gig 0

    However when performing a switch report I see the following adjancies:

    AP1-68
    AP2-68
    AP3-68
    AP4-68
    AP5-68
    AP6-68
    AP7-68
    AP8-68
    AP9-68
    s1-sfmh-core
    s2-sfmh-68-09-2
    WIP1-68
    WIP2-68

    Is there a workaround so I can see the full hostname when a '_' character is used? Thanks --Ryan

     
    • Ryan Mahoney

      Ryan Mahoney - 2014-12-30

      Jonathan - in reviewing your source code I think the issue may be in the following line, found in the iosscraper's getCDP subroutine:
      // Save remote device name
      if ( !($remoteDevice) && $line =~ /^Device\sID:\s+([A-Za-z0-9.-]+)/ ) {

      I am not a regular expression expert, but it appears you are only expecting to capture alphanumeric, '.', and '-'

      Would there be a reason we couldn't modify this line to include '_' ?

       
  • Ryan Mahoney

    Ryan Mahoney - 2015-01-05

    Jonathan - it does not appear to have worked. I made the modification last week and the truncated hostnames still show up when I do a switch report. Am I correct in assuming that the updated functionality should have overwritten the original n_hostnames in the neighbor table?

     
  • Jonathan Yantis

    Jonathan Yantis - 2015-01-06

    Ryan,

    Give this a shot. If it doesn't work, I'll try to create an underscore switch name and test on my end:

    if ( !($remoteDevice) && $line =~ /^Device\sID:\s+([A-Za-z0-9.-_]+)/ ) {

    Jonathan

     
  • Ryan Mahoney

    Ryan Mahoney - 2015-01-30

    Excellent! I will install the files and let you know! --Ryan

     

Log in to post a comment.