---
layout: docs
page_title: network block in the job specification
description: |-
Configure task group networking requirements in the `network` block of the Nomad job specification. Configure network mode, hostname, port, DNS, and Container Network Interface (CNI) arguments. Review configuration examples of dynamic ports, static ports, mapped ports, bridge mode, host networks, DNS, and CNI networks.
---
# `network` block in the job specification
The `network` block specifies the networking requirements for the task group,
including the network mode and port allocations. When scheduling jobs in
Nomad they are provisioned across your fleet of machines along with other jobs
and services. Because you don't know in advance what host your job will be
provisioned on, Nomad will provide your tasks with network configuration when
they start up.
Note that this document only applies to services that want to _listen_ on a
port. Batch jobs or services that only make outbound connections do not need to
allocate ports, since they will use any available interface to make an outbound
connection.
```hcl
job "docs" {
group "example" {
network {
port "http" {}
port "https" {}
port "lb" {
static = 8889
}
}
}
}
```
### Network modes
When the `network` block is defined with `bridge` as the networking mode,
all tasks in the task group share the same network namespace. This is a prerequisite for
[Consul Connect](/nomad/docs/integrations/consul-connect). Tasks running within a
network namespace are not visible to applications outside the namespace on the same host.
This allows [Connect][]-enabled applications to bind only to localhost within the shared network stack,
and use the proxy for ingress and egress traffic.
To use `bridge` mode, you must have the [reference CNI
plugins](https://github.com/containernetworking/plugins/releases/tag/v1.0.0)
installed at the location specified by the client's [`cni_path`]
configuration. These plugins are used to create the bridge network and
configure the appropriate iptables rules.
Network modes are only supported in allocations running on Linux clients.
All other operating systems use the `host` networking mode.
~> **Warning:** To prevent any type of external access when using `bridge`
network mode make sure to bind your workloads to the loopback interface
only. Refer to the [Bridge networking][docs_networking_bridge] documentation
for more information.
## Parameters
- `mbits` ([_deprecated_](/nomad/docs/upgrade/upgrade-specific#nomad-0-12-0) int: 10) - Specifies the bandwidth required in MBits.
- `port` ([Port](#port-parameters): nil) - Specifies a TCP/UDP port
allocation and can be used to specify both dynamic ports and reserved ports.
- `mode` `(string: "host")` - Mode of the network. This option is only supported
on Linux clients. The following modes are available:
- `none` - Task group will have an isolated network without any network interfaces.
- `bridge` - Task group will have an isolated network namespace with an interface
that is bridged with the host. Note that bridge networking is only
currently supported for the `docker`, `exec`, `raw_exec`, and `java` task
drivers.
- `host` - Each task will join the host network namespace and a shared network
namespace is not created.
- `cni/` - Task group will have an isolated network namespace
with the network configured by CNI.
- `hostname` `(string: "")` - The hostname assigned to the network namespace. This
is currently only supported using the [Docker driver][docker-driver] and when the
[mode](#mode) is set to [`bridge`](#bridge). This parameter supports
[interpolation](/nomad/docs/runtime/interpolation).
- `dns` ([DNSConfig](#dns-parameters): nil) - Sets the DNS
configuration for the allocations. By default all task drivers will inherit
DNS configuration from the client host. DNS configuration is only supported on
Linux clients at this time. Note that if you are using a `mode="cni/*`, these
values will override any DNS configuration the CNI plugins return.
- `cni` ([CNIConfig](#cni-parameters): nil) - Sets the custom CNI
arguments for a network configuration per allocation, for use with `mode="cni/*`.
### `port` parameters
- `static` `(int: nil)` - Specifies the static TCP/UDP port to allocate. If omitted, a
dynamic port is chosen. We **do not recommend** using static ports, except
for `system` or specialized jobs like load balancers.
- `to` `(string:nil)` - Applicable when using "bridge" mode to configure port
to map to inside the task's network namespace. Omitting this field or
setting it to `-1` sets the mapped port equal to the dynamic port allocated
by the scheduler. The `NOMAD_PORT_