at 17.09-beta 1.3 kB view raw
1<section xmlns="http://docbook.org/ns/docbook" 2 xmlns:xlink="http://www.w3.org/1999/xlink" 3 xmlns:xi="http://www.w3.org/2001/XInclude" 4 version="5.0" 5 xml:id="sec-ipv4"> 6 7<title>IPv4 Configuration</title> 8 9<para>By default, NixOS uses DHCP (specifically, 10<command>dhcpcd</command>) to automatically configure network 11interfaces. However, you can configure an interface manually as 12follows: 13 14<programlisting> 15networking.interfaces.eth0.ip4 = [ { address = "192.168.1.2"; prefixLength = 24; } ]; 16</programlisting> 17 18Typically you’ll also want to set a default gateway and set of name 19servers: 20 21<programlisting> 22networking.defaultGateway = "192.168.1.1"; 23networking.nameservers = [ "8.8.8.8" ]; 24</programlisting> 25 26</para> 27 28<note><para>Statically configured interfaces are set up by the systemd 29service 30<replaceable>interface-name</replaceable><literal>-cfg.service</literal>. 31The default gateway and name server configuration is performed by 32<literal>network-setup.service</literal>.</para></note> 33 34<para>The host name is set using <option>networking.hostName</option>: 35 36<programlisting> 37networking.hostName = "cartman"; 38</programlisting> 39 40The default host name is <literal>nixos</literal>. Set it to the 41empty string (<literal>""</literal>) to allow the DHCP server to 42provide the host name.</para> 43 44</section>