We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

How can I get the name of the client computer?

I want to know the client computer name that makes changes to the system. I tried


But does not return data, while its returns data


this "gethostbyaddr" available for Phalcon?

There is no way that you can get your client's computer name (like "Stefans-PC"). But you can do a reverse IP lookup and find the hostname (which is not the same!).

You get client's IP with $this->request->getClientAddress() and then try to resolve it to a hostname using the function you mentioned. For an example, if you reverse lookup my IP which might be, let's say xxx.xxx.xxx , my ISP would respond with xxx-xxx-xxx.adsl-a-5.sezampro.rs.

NOTE You can use $this->request->getClientAddress(true) if you're behind a load balancer / your user's request is being forwarded. For clarification, please refer to the docs.


Yes. gethostbyaddr returns no data. and I can not find it in the documentation so i asked .¿gethostbyaddr is available for Phalcon?

It has nothing to do with phalcon, it's native function. That means you can use it from anywhere from where you execute PHP code. It doesn't return data because their ISP does not want to return that data. It's ISP decision if there will be an answer.

edited Jun '16 is local, private IPv4 address, it has nothing to do with ISP. If you have your local DNS on the network, you can make static entry... or just add it in your /etc/hosts otherwise, and native php function gethostbyaddr will then return something like yourComputer.lan.

Be aware that in a real world application, this function can slow down your application by 30-50% during peak load. Reverse DNS lookups are perfect candidate for a message broker task, i.e. Beanstalkd in Phalcon.


Then in a process audit system, which save data they would recommend me to give indication of where there were changes in the system, you can get other information such as the browser or things like that?

Audit systems can be complex, depending on a project type (i.e. working for a financial institution is not the same as working for small website) and has nothing to do with reverse DNS lookups.

Most (all?) workstations aren't going to have a DNS entry anyway. The IP is about as good as you can get.


The dynamic IP changes on local machines, are not fixed, if someone made a change would not know who it was. They are asking me things in the thesis, of course in addition to the user

edited Jun '16

Most (all?) workstations aren't going to have a DNS entry anyway. The IP is about as good as you can get.

Uhmm. Behind firewall/NAT/router, you have public IP address which usually has PTR (reverse DNS) record set by your ISP. Each and every computer behind that NAT will share that IP and thus that domain PTR record. Test yours here: https://myip.dk

Now, if you're deploying your application in an enterprise (i.e. Intranet), there is also big chance that local clients are in a domain, and will also have PTR's. For instance, in our development company we have such thing. So my computer will always have stamster.company static DNS.

So @jeiel needs to clarify which scenario he's looking at. In any case, even if there is no reverse DNS hostname for a certain IP, gethostbyaddr will simply return IP as a hostname.

And top conclusion would be DO NOT run reverse DNS of any kind on a production system. Use message broker instead.