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 address = "192.168.1.2";
11 prefixLength = 24;
12 } ];
13}
14```
15
16Typically you'll also want to set a default gateway and set of name
17servers:
18
19```nix
20{
21 networking.defaultGateway = "192.168.1.1";
22 networking.nameservers = [ "8.8.8.8" ];
23}
24```
25
26::: {.note}
27Statically configured interfaces are set up by the systemd service
28`interface-name-cfg.service`. The default gateway and name server
29configuration is performed by `network-setup.service`.
30:::
31
32The host name is set using [](#opt-networking.hostName):
33
34```nix
35{
36 networking.hostName = "cartman";
37}
38```
39
40The default host name is `nixos`. Set it to the empty string (`""`) to
41allow the DHCP server to provide the host name.