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