Can you specify ports in etc/hosts?

Is there a way to specify a port for IP addresses listed in the etc/hosts file, or, does it default to 80 (or something else) and that's what you're stuck with?

According to what protocol you are using, the port is specified.

If you are sending mail it uses SMTP on port 25.
If you are using a browser and put in a host, it uses http on port 80.

I don't believe you can put ports in /etc/hosts (or actually that you would want to - it would just break things). You might want to look at /etc/services which allows you to change where your system listens for different services. Changing http from port 80 to other ports is done all the time. Changing other services (such as SMTP) is not normally done since servers trying to connect to your server will not know about it.

Read the man page on services.

No.

In the /etc/hosts file you can only put IP's, hostname and aliases.

Regards. Hugo.

Thanks for the info. I had come to the same conclusion about that yesterday, fooling around with settings in the file.