# Check and change a machine's network

Check that a machine is online, and connect machines to each other on a network of their own.

## Check a machine's network

Once the guest agent answers, OSMates checks the machine's address, DNS, and clock. If a check fails, the machine window shows **No Internet Connection**. On a host-only network, only the address is checked.

To check in Terminal, read the Network and Clock lines:

```sh
osmates vm info dev
```

## Put machines on a shared or host-only network

A new machine has its own NAT network, with IPv6 when your Mac has it. It reaches your Mac and the internet, and nothing else reaches it.

1. Shut down the machine.
2. Choose **Machine > Machine Settings**, then click **Network**.
3. Under **Connection**, choose **Shared Network** or **Host-Only Network**.
4. Choose a network, or click **New Network** to make one.
5. Start the machine.

Machines on the same network reach each other, whatever their system. `osmates vm list` shows each network and its machines.

| Connection | In Terminal | Reaches |
|---|---|---|
| Shared with the Mac | `nat` | Your Mac and the internet |
| Shared Network | `shared:lab` | Machines on it, your Mac, and the internet |
| Host-Only Network | `host-only:lab` | Machines on it and your Mac |

To change the network in Terminal:

```sh
osmates vm set dev --network shared:lab
```

A host-only network has no DNS server, and it isn't a firewall. To keep a guest from routing through your Mac, [limit what it reaches](https://osmates.com/docs/egress#limit-what-a-machine-reaches).

## Give a machine a fixed address

A machine on a shared or host-only network can keep one IPv4 address. Set it in Terminal, with every machine on the network shut down:

```sh
osmates vm set dev --network host-only:lab --address 10.77.0.10
```

The first fixed address sets the network's subnet, here 10.77.0.0/24. Use a private range that your Mac doesn't already reach through Wi-Fi or a VPN. To remove the address, set `--network` again without `--address`.

## Reach names your Mac's VPN knows

A machine follows your Mac's VPN within 30 seconds. A Linux machine on a NAT or shared network resolves names through your Mac. Names your VPN's DNS knows then work in it.

This needs systemd-resolved in the guest, as Debian, Ubuntu, and Fedora have. To check a name:

```sh
osmates vm exec dev -- getent hosts intranet.corp.example
```

## Start a machine whose network doesn't start

If macOS network sharing doesn't answer within about 8 seconds, the start stops and names the step that failed. To start once without a network, click **Start Without Network**, or in Terminal:

```sh
osmates vm start dev --no-network
```

To restore sharing, see [Machine has no network after macOS stops sharing it](https://osmates.com/docs/known-issues#machine-has-no-network-after-macos-stops-sharing-it).

## If it doesn't work

- [Connections stall when your Mac's MTU is below 1500](https://osmates.com/docs/known-issues#connections-stall-when-your-macs-mtu-is-below-1500)
- [Shared network has no connection after a VPN turns on or off](https://osmates.com/docs/known-issues#shared-network-has-no-connection-after-a-vpn-turns-on-or-off)
