16

I'd like to assign a friendly name to a port number, how should I do it?

For example: I'd like "0.0.0.0:my-service-name" translates to "0.0.0.0:1234"

1 Answer 1

29

Yes, you can do this, by adding your port definition to /etc/services. For a TCP service, you’d add

my-service-name    1234/tcp

Once that’s done, you’ll be able to write “0.0.0.0:my-service-name” instead of “0.0.0.0:1234”.

The canonical list of services is maintained by the IANA, but you can add local definitions; you might even see a “# Local services” comment at the end of your /etc/services file already.

2
  • It's important to note that this will only work on your local machine. If you want some other computers on the network to use that name, you'll have to modify /etc/services on those machines. Sep 26, 2020 at 22:41
  • 1
    @user431397 it won’t, /etc/services is a conffile (see /var/lib/dpkg/info/netbase.conffiles). More generally, /etc belongs to the system administrator, it’s a bug if a package doesn’t preserve changes made there. Sep 27, 2020 at 8:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .