Expose all ports between tasks

My application requires creating new connections between containers at runtime, on ports determined when they are needed. Almost every Nomad example shows specifying a port mapping that is predetermined at job creation.
What is the right approach for:

  1. Letting tasks know the IP address/DNS name of another task so it can know how to reach that host.
  2. Nomad will not restrict traffic on ports that aren’t specified in the job file.

Preferably this would be using a bridge network so only the tasks in the job specification can communicate, but I have not had any luck getting this to work.
This is default behavior when using Docker Compose, as containers can be referred to by their name and the bridge network will perform DNS to find the correct hosts. Can this be done using Nomad?