1# IPv4 Configuration {#sec-ipv4}
2
3By default, NixOS uses DHCP (specifically, `dhcpcd`) to automatically
4configure network interfaces. However, you can configure an interface
5manually as follows:
6
7```nix
8{
9 networking.interfaces.eth0.ipv4.addresses = [
10 {
11 address = "192.168.1.2";
12 prefixLength = 24;
13 }
14 ];
15}
16```
17
18Typically you'll also want to set a default gateway and set of name
19servers:
20
21```nix
22{
23 networking.defaultGateway = "192.168.1.1";
24 networking.nameservers = [ "8.8.8.8" ];
25}
26```
27
28::: {.note}
29Statically configured interfaces are set up by the systemd service
30`interface-name-cfg.service`. The default gateway and name server
31configuration is performed by `network-setup.service`.
32:::
33
34The host name is set using [](#opt-networking.hostName):
35
36```nix
37{ networking.hostName = "cartman"; }
38```
39
40The default host name is `nixos`. Set it to the empty string (`""`) to
41allow the DHCP server to provide the host name.