at 18.09-beta 1.5 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 <title>IPv4 Configuration</title> 7 8 <para> 9 By default, NixOS uses DHCP (specifically, <command>dhcpcd</command>) to 10 automatically configure network interfaces. However, you can configure an 11 interface manually as follows: 12<programlisting> 13<link linkend="opt-networking.interfaces._name__.ipv4.addresses">networking.interfaces.eth0.ipv4.addresses</link> = [ { 14 address = "192.168.1.2"; 15 prefixLength = 24; 16} ]; 17</programlisting> 18 Typically you’ll also want to set a default gateway and set of name 19 servers: 20<programlisting> 21<xref linkend="opt-networking.defaultGateway"/> = "192.168.1.1"; 22<xref linkend="opt-networking.nameservers"/> = [ "8.8.8.8" ]; 23</programlisting> 24 </para> 25 26 <note> 27 <para> 28 Statically configured interfaces are set up by the systemd service 29 <replaceable>interface-name</replaceable><literal>-cfg.service</literal>. 30 The default gateway and name server configuration is performed by 31 <literal>network-setup.service</literal>. 32 </para> 33 </note> 34 35 <para> 36 The host name is set using <xref linkend="opt-networking.hostName"/>: 37<programlisting> 38<xref linkend="opt-networking.hostName"/> = "cartman"; 39</programlisting> 40 The default host name is <literal>nixos</literal>. Set it to the empty string 41 (<literal>""</literal>) to allow the DHCP server to provide the host name. 42 </para> 43</section>