# Networks and addresses

Which addresses an instance gets, how networks and subnets place it, and what security groups filter.

## Addresses

| Address             | When                                                                                         |
| ------------------- | -------------------------------------------------------------------------------------------- |
| Public IPv4         | Unless you launch with `enablePublicIpv4: false`. Included in the instance price.            |
| Public IPv6         | Always.                                                                                      |
| Private IPv4        | An address in the instance's network.                                                        |
| Pinned private IPv4 | When you launch with a `subnetId`: an address in that subnet's range.                        |
| Elastic IPv4        | When you associate an [elastic IP](use-an-elastic-ip.md); it stays when the machine changes. |

An instance without a public IPv4 reaches the internet over IPv4 only through its network's
[NAT gateway](add-a-nat-gateway.md), and only if that gateway was available when the instance was
launched; otherwise it has IPv6 only. On your organization's own hosts, launching without a public
IPv4 is refused.

## Networks

A network (a VPC) is a private IPv4 range in one region, from `/8` to `/24` and in the private
ranges of RFC 1918. It spans every zone of the region. Every instance joins one: the network you
name with `vpcId`, or the region's **default network**, which is created (`10.0.0.0/16`) the first
time a launch needs it and cannot be deleted (`400` "Cannot delete the default VPC"). The default
network counts toward the network quota; when that quota is full, the launch that needs it is
refused with `409`. See [Create a network](create-a-network.md).

## Subnets

A subnet is part of a network's range (`/16` to `/28`, inside the network, not overlapping another
subnet) in one zone. A network has none until you create one; then **Whole network** in the
console means "any free address in the range". An instance launched with a `subnetId` gets an
address in the subnet and runs in its zone. See [Create a subnet](create-a-subnet.md).

## Security groups

A security group is a set of rules in front of the public side of every instance it is attached
to. From the internet, only what an inbound rule of an attached group allows gets in; outbound is
allowed unless a group has outbound rules, after which only what they allow leaves. Traffic inside
the private network is not filtered. An instance with no group attached is not filtered at all:
every port is open to the internet. Groups belong to the organization, not to a network: any group
can be attached to any instance. See [Create a security group](create-a-security-group.md).

Rules name addresses (a CIDR block, IPv4 or IPv6, or a single address); a rule cannot name another
security group as its source.

## Related

- [Launch an instance](launch-an-instance.md)
- [Instances on your own hosts](own-hosts.md)
