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