Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpIPAM 1.6 scan subnet returns live hosts but no hostnames #3746

Closed
kiweegie opened this issue Jan 30, 2023 · 11 comments
Closed

phpIPAM 1.6 scan subnet returns live hosts but no hostnames #3746

kiweegie opened this issue Jan 30, 2023 · 11 comments

Comments

@kiweegie
Copy link

Describe the bug
When using scan subnets feature (Discovery scans:Ping scan using fping) live hosts are discovered however hostnames are not returned. The scans are using DNS Servers for the applicable site.

NSlookup test from the server itself resolves hosts fine.

phpIPAM version
1.6.0

Versions of phpIPAM known to contain the issue (delete as appropriate).

Seeing same thing on our old instance running v1.4.3

Your Environment (please supply the following information):

  • phpIPAM version: 1.6.0
  • OS Ubuntu 22.04
  • PHP version 7.4.33
  • Webserver Apache 2.4.52
  • Database MariaDB 10.6.11

Steps To Reproduce
Please include steps to reproduce the issue:
Administration > phpIPAM settings > Resolve DNS names = ON
Administration > phpIPAM settings > Scan type = fping
Subnets > Add Subnet > Set "Check hosts", "Discover new hosts" and "Resolve DNS names" = Yes

Screenshots and error logs
debugging is set to true in config.php

This is also set in the config.php - is this correct? Should these be edited to allow DNS names to be returned?

# pingCheck.php script parameters
$config['ping_check_send_mail']        = true;       // true/false, send or not mail on ping check
$config['ping_check_method']           = false;      // false/ping/pear/fping, reset scan method
# discoveryCheck.php script parameters
$config['discovery_check_send_mail']   = true;       // true/false, send or not mail on discovery check
$config['discovery_check_method']      = false;      // false/ping/pear/fping, reset scan method
# remove_offline_addresses.php script parameters
$config['removed_addresses_send_mail'] = true;       // true/false, send or not mail on pomoving inactive addresses
$config['removed_addresses_timelimit'] = 86400 * 7;  // int, after how many seconds of inactivity address will be deleted (7 days)
# resolveIPaddresses.php script parameters
$config['resolve_emptyonly']           = true;       // if true it will only update the ones without DNS entry!
$config['resolve_verbose']             = true;       // verbose response - prints results, cron will email it to you!
$config['disable_main_login_form']     = false;      // disable main login form if you want use another authentification method by default (SAML, LDAP, etc.)

Additional Info
2 nodes running keepalived with mariadb set as master-master replication.
Modules enabled from default = IP request, SNMP Module,

Cheers Kiweegie.

@kiweegie
Copy link
Author

kiweegie commented Feb 3, 2023

Just a follow up on this one, The old IPAM setup this was to replace is running on Ubuntu 16.04 and phpIPAM version 1.4.3 and the following versions of mariadb and php

mysql Ver 15.1 Distrib 10.2.12-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

PHP 7.0.33-0ubuntu0.16.04.16 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.33-0ubuntu0.16.04.16, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

Comparing the 2 versions of the resolveIPaddresses.php code they are near enough identical - only difference is the stanzas handling error reporting.

Old:

// set to 1 in case of errors
ini_set('display_errors', 0);
error_reporting(E_ERROR);

New:

# Don't corrupt output with php errors!
disable_php_errors();

Name resolution on the new server itself works fine from the OS.

If I do a manual scan of a subnet on old server hostnames are returned alongside IP. On the new server the hostname field remains blank.

I've trawled through a number of older posts in here which have had similar issues albeit on older versions of phpIPAM but none appeared to be pertinent to my situation. If anyone out there has any suggestions I'm all ears.

regards Kiweegie

@kiweegie
Copy link
Author

kiweegie commented Feb 6, 2023

I've just tested running the cronjob manually as below

sudo /usr/bin/php /var/www/html/phpipam/functions/scripts/resolveIPaddresses.php

It pulls back hostnames back but only does 4 and then stalls.

updated ip address 10.**.**.* with hostname hostname1
updated ip address 10.**.**.* with hostname hostname2
updated ip address 10.**.**.* with hostname hostname3
updated ip address 10.**.**.* with hostname hostname4

If I repeat the command it picks up same 4 devices and then stops. Web UI is populated with the hosts but this is only working for a single subnet.

I've compared settings on that subnet versus others and same settings across the board so I dont understand why this one's being scanned OK but the rest are not. It's also not the first subnet listed so it doesn't appear to be doing in some sort of order then failing far as I can tell

regards Kiweegie.

@kiweegie
Copy link
Author

kiweegie commented Feb 6, 2023

To add to above, despite the hostnames being returned OK on this one subnet in the web UI it doestn't reflect successful scan under Resolve DNS names as shown

image

Per another post i've seen on here I've amended the crons run every 90 mins in case its a timeout issue of some sort. I've seen when running ping scan manually on large subnet it does seem to take ages to complete.

@mattvancn
Copy link

I have the same question.
running the cronjob manually.
It pulls back about 20 hostnames in same subnet,but I have more than 10 subnets and about 100 hosts in each subnets.
Kind Regards.

@zzstopps
Copy link

Same issue on 1.51 for me

phpIPAM version: 1.5.1
OS: Oracle linux 8
PHP version 7.4.33
Webserver Apache 2.4.37
Database MariaDB 10.3.35

@zzstopps
Copy link

zzstopps commented Jun 1, 2023

@kiweegie did you manage to resolve this? i created a 1.6 server but still have the same issue

@kiweegie
Copy link
Author

kiweegie commented Jun 2, 2023

No I'm afraid not. Not sure if my set up is exactly same as yours or not as I've got a 2 node setup using keepalived for failover between the 2.

Ubuntu 22.04
phpIPAM version 1.6 db version 39
PHP 7.4.33
Apache 2.4.52
MariaDB 10.6.12-MariaDB

Using the UI to scan subnets appears to do nothing. I get response in that it sees live hosts and I get a list of IPs which are "live" but without hostnames attached its not much use.

Crontab setup as follows

*/90 * * * * /usr/bin/php /var/www/html/phpipam/functions/scripts/pingCheck.php
*/90 * * * * /usr/bin/php /var/www/html/phpipam/functions/scripts/discoveryCheck.php
*/120 * * * * /usr/bin/php /var/www/html/phpipam/functions/scripts/resolveIPaddresses.php

If I run each of these commands from terminal from top to bottom I get output as follows

pingCheck: Scan start, 345 subnets
(this takes a good while to complete given the number of subnets we have)

discoveryCheck: Scan start, 345 subnets
(again this hangs for a good while before returning anything)

/usr/bin/php /var/www/html/phpipam/functions/scripts/resolveIPaddresses.php
this finishes very quickly and returns nothing.

I've fired up my old server running phpIPAM 1.4.3 (other versions below) and scanning on that works and returns hostnames when scanning from the UI. I did not have crontab setup to do this automatically before.

Ubuntu 16.04.7
PHP 7.0.33-0ubuntu0.16.04.16
Apache/2.4.18 (Ubuntu)
10.2.12-MariaDB

However if on the old server i try and run equivalent scripts (diff path) I get responsese immediately (loads of information flying past on screen).

/usr/bin/php /var/www/phpipam/functions/scripts/pingCheck.php
/usr/bin/php /var/www/phpipam/functions/scripts/discoveryCheck.php
/usr/bin/php /var/www/phpipam/functions/scripts/resolveIPaddresses.php

I've tried to compare these scripts between versions and can see various differences but not being a developer not entirely sure what I should be looking for.

Checking syslog on the new server I'm seeing this error

[Warning] Aborted connection 7165 to db: 'phpipam' user: 'phpipamDBUser' host: 'localhost' (Got an error reading communication packets)

regards Kiweegie.

@bj1983
Copy link

bj1983 commented Jun 21, 2023

Same Problem here with phpIPAM as Docker-Compose Setup -> phpipam/phpipam-www:1.5x
The "resolveIPaddresses.php" resolves nothing.

@kiweegie
Copy link
Author

kiweegie commented Aug 1, 2023

Not had much spare time of late to look at this but took a few minutes this evening to check a couple of other bits. Figured as myself and one other on this post have been using same PHP version (7.4.33) but different phpIPAM versions then it might be something wrong in the PHP version.

I tested via https://www.php.net/manual/en/function.gethostbyname.php with following basic php script and it returns a valid IP address when run

<?php
$ip = gethostbyname('hostname');

echo $ip;
?>

@zzstopps
Copy link

zzstopps commented Aug 2, 2023

@kiweegie but we have the IP not the hostname, it's something in the reverse lookup i'm guessing

@kiweegie
Copy link
Author

Revisting this to advise I found the fix and it was simple in the end. Don't recall seeing this documented anywhere but looking at another issue today came across an old post which made the comment that they'd incorrectly added name servers on phpIPAM using hostname not IP. Guess what I'd done? Yep, added Name servers via hostname. I amended to using IP address and the hostnames now populate. Feel kinda stupid here but didn't see anything in documentation to mention that was a requirement. Hoperfully this helps out someone else in the same spot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants