If ifconfig is not installed, how does ubuntu tell you to install net-tools in order to use ifconfig? Why doesn't Debian do this? [duplicate]

How does Ubuntu know which package I need to install to use that command?

The package that does this is actually called command-not-found and it uses a cache to gather all the commands installed (update-command-not-found does this).