|
|
<?xml version="1.0" encoding="utf-8"?>
<chapter label="5" id="networking">
<title>Networking</title>
<highlights><para>In this chapter, we will discuss how to configure your Adélie Linux system for networking. Wired, wireless, and VPN connections using both static and dynamic IP addressing will be covered. In addition, advanced topics including interface bondage and KVM configuration will also be discussed.</para></highlights>
<section id="introduction5">
<title>Introduction</title>
<para>The Adélie Linux system uses <firstterm><package>netifrc</package></firstterm> as its network configuration and management system. The netifrc system uses a declarative configuration syntax in a single file, <filename>/etc/conf.d/net</filename>, for ease of administration. All main system network configuration is declared in this file. Some additional configuration may be required for wireless or VPN connections; notably, wireless connections require WPA Supplicant to be configured using either <package>wpa_gui</package> (on computers that use X11), or in the <filename>/etc/wpa_supplicant/wpa_supplicant.conf</filename> file.</para>
<para>The default configuration for the Adélie Linux system uses the traditional Linux interface names (such as "eth0", "eth1", and "wlan0"). If you prefer the new "predictable" interface names (such as "enP2p36s15f0" or "wlp9s0"), refer to <xref linkend="crappy_udev_ifs" />.</para>
<section>
<title>A netifrc primer</title>
<para>The netifrc configuration file consists of INI-style configuration variables. For example, <literal>config_eth0="dhcp"</literal> sets the variable <varname>config_eth0</varname> to the value <literal>dhcp</literal>. By default, all interfaces on the system that are enabled will attempt to retrieve a DHCP address. Retrieving a DHCP address requires the <package>dhcpcd</package> package to be installed.</para>
<para>To enable a network interface, you must create a symbolic link to <filename>/etc/init.d/net.lo</filename> in <filename class="directory">/etc/init.d</filename> named <filename>net.<replaceable>IFACE</replaceable></filename> where <replaceable>IFACE</replaceable> is the name of the interface. For example, for the interface named <literal>eth0</literal>, you would run <command>ln -s /etc/init.d/net.lo /etc/init.d/net.eth0</command>. Next, you need to add the service to the default runlevel. As noted in <xref linkend="enable_disable_rc" />, you would run <command>rc-update add net.<userinput>IFACE</userinput> default</command> to enable the net.<replaceable>IFACE</replaceable> service. You may then <link linkend="start_stop_rc">start the service</link>, assuming the interface has been configured properly in <filename>/etc/conf.d/net</filename>.</para>
<para>To disable a network interface, you must first <link linkend="start_stop_rc">stop it</link>, if it is running. Next, <link linkend="enable_disable_rc">remove it from the default runlevel</link> (<command>rc-update del net.<userinput>IFACE</userinput> default</command>). Finally, remove the symbolic link in <filename class="directory">/etc/init.d</filename>.</para>
</section>
<section>
<title>Identifying adaptors</title>
<para>Before we begin configuring the network, we will list the network adaptors available on your computer. This will ensure that the adaptor or adaptors were detected successfully by the kernel. To do this, ensure the <package>iproute2</package> package is installed, and run the command <command>ip link</command> as root.</para>
</section>
</section>
<section id="wired">
<title>Wired connections</title>
<para>For the purposes of this handbook, a <firstterm>wired connection</firstterm> is a connection to a network that utilises Ethernet. While the Adélie Linux system supports ATM, CAN bus, IEEE 1394, and Token Ring networking, these connection types are exceedingly rare and out of the scope of this handbook.</para>
<section id="how2dhcp">
<title>Dynamic addressing</title>
<para>To explicitly configure an interface to use dynamic addressing via DHCP, set <varname>config_<replaceable>IFACE</replaceable></varname>=<literal>"dhcp"</literal>, where <replaceable>IFACE</replaceable> is the interface you wish to use dynamic addressing. For more information on customising dynamic addressing, refer to <xref linkend="dhcphax" />.</para>
</section>
<section id="how2static">
<title>Static addressing</title>
<para></para>
<section id="how2dns">
<title>Configuring DNS resolution</title>
<para>When you use static addressing, you additionally need to configure DNS resolution. To do this, you must add one or more <firstterm>nameserver</firstterm>s (DNS resolution systems) in <filename>/etc/resolv.conf</filename>. (Note that there is no 'e' at the end of <filename>resolv.conf</filename>.) Adding more than one server will allow your system to have a fallback if one nameserver is down or not responding.</para>
<para>There are a few nameservers on the Internet that respect user privacy, including <ulink url="https://labs.ripe.net/Members/stephane_bortzmeyer/quad9-a-public-dns-resolver-with-security">Quad9</ulink> and <ulink url="https://dns.watch/">DNS.WATCH</ulink>. In this example, we will configure our system to use Quad9 over IPv6, with Quad9 and DNS.WATCH over IPv4 as fallbacks:</para>
<example>
<title><filename>/etc/resolv.conf</filename> file using Quad9 and DNS.WATCH</title>
<programlisting>
nameserver 2620:fe::fe
nameserver 9.9.9.9
nameserver 84.200.69.80
</programlisting>
</example>
</section>
</section>
</section>
<section id="wireless">
<title>Wireless connections</title>
<para></para>
<section id="wpa">
<title>WPA-based authentication</title>
<warning><title>Not Yet Written</title><para>This section has not yet been written.</para></warning>
</section>
<section id="radius">
<title>RADIUS (certificate-based) authentication</title>
<warning><title>Not Yet Written</title><para>This section has not yet been written.</para></warning>
</section>
<section id="multi_ap">
<title>Configuring for multiple access points</title>
<warning><title>Not Yet Written</title><para>This section has not yet been written.</para></warning>
</section>
</section>
<section id="vpn">
<title>VPN connections</title>
<para></para>
<section id="openvpn">
<title>OpenVPN</title>
<warning><title>Not Yet Written</title><para>This section has not yet been written.</para></warning>
</section>
<section id="strongswan">
<title>StrongSwan</title>
<warning><title>Not Yet Written</title><para>This section has not yet been written.</para></warning>
</section>
</section>
<section id="kvm">
<title>Virtual machine networking</title>
<para></para>
<section id="hostonly">
<title>Networking guests with each other only</title>
<warning><title>Not Yet Written</title><para>This section has not yet been written.</para></warning>
</section>
<section id="bridged_kvm">
<title>Sharing a host network with guests</title>
<para>The Adélie Linux system can be configured to provide bridged networking to a QEMU virtual machine or KVM guest using TAP networking. You will need the <package>iproute2</package> package installed.</para>
<para>First, we will need to add a <firstterm>bridge</firstterm> to netifrc. A bridge allows multiple network adaptors to combine multiple network segments into a single aggregate. For our purposes, we will be combining the physical network adaptor on the host with the virtual network adaptors on each guest. The bridge will have your physical network adaptor as its first member. This way, no network reconfiguration will be required when you start or stop virtual machines. You will need to move the configuration for your physical network adaptor to the bridge, so that all members of the bridge may share that connection. In the following example, the interface <literal>eth0</literal> is the physical adaptor and the bridge is set to use a static IPv6 address, which will then be used by the physical adaptor as well.</para>
<example>
<title>Configuring <filename>/etc/conf.d/net</filename> to use bridged networking</title>
<programlisting>
config_eth0="null"
bridge_br0="eth0"
config_br0="2001:db8::2/32"
routes_br0="default via 2001:db8::1"
</programlisting>
</example>
<para>Note that the physical adaptor must still be specified with a <literal>"null"</literal> configuration. This ensures that the link will still be activated and network traffic will still flow. If you are using DHCP, you may simply use <code>config_br0="dhcp"</code>.</para>
<para>You will then need to replace your <literal>net.<replaceable>IFACE</replaceable></literal> file with a <literal>net.br0</literal> file in <filename class="directory">/etc/init.d</filename>. For example:</para>
<example>
<title>Replacing a physical adaptor with bridged adaptor in OpenRC</title>
<screen>
computer ~ # rc-update del net.eth0
computer ~ # service net.eth0 stop
computer ~ # mv /etc/init.d/net.eth0 /etc/init.d/net.br0
computer ~ # rc-update add net.br0 default
computer ~ # service net.br0 start
</screen>
</example>
<warning><title>Warning</title><para>You will momentarily lose network connectivity after stopping net.<replaceable>IFACE</replaceable>. Do not perform these steps while connected to the machine over the network.</para></warning>
<para>Now we need to create scripts for QEMU (or KVM) to use. The <filename>/etc/qemu-ifup</filename> script should be created as follows:</para>
<programlisting language="shell">
#!/bin/sh
ip tuntap add mode tap name $1
ip link set dev $1 master br0
ifconfig $1 up
</programlisting>
<para>The <filename>/etc/qemu-ifdown</filename> script should be created as follows:</para>
<programlisting language="shell">
#!/bin/sh
ifconfig $1 down
ip tuntap del name $1
</programlisting>
<para>You may now start your QEMU or KVM virtual machines with network access by adding <literal>-net tap</literal> to the command line. Note that if you have more than one guest that needs network access, you will need to set a custom MAC address for each NIC. Otherwise there will be MAC collisions and networking may not work correctly. For example:</para>
<informalexample><para><code>qemu-system-ppc64 -accel kvm -m 768 -drive file=/dev/gwyn/testvm,format=raw -net nic,model=virtio,macaddr=02:00:00:00:00:01 -net tap -machine pseries-2.12</code></para></informalexample>
<para>This will start a machine with network access and a MAC address of <literal>02:00:00:00:00:01</literal>.</para>
</section>
</section>
<section id="advanced">
<title>Advanced topics</title>
<para></para>
<section id="crappy_udev_ifs">
<title>Advanced: Using "predictable" network interface names</title>
<warning><title>Not Yet Written</title><para>This section has not yet been written.</para></warning>
</section>
<section id="multi_if">
<title>Advanced: Multiple interfaces</title>
<para></para>
<para>Note that by default, all interfaces must be active before the rest of the system will consider the network to be active. This will cause network services to delay start-up until all interfaces are active. If this is not desired, you may set <varname>rc_depend_strict</varname> to <literal>NO</literal> in <filename>/etc/rc.conf</filename>.</para>
</section>
<section id="bondage">
<title>Advanced: Interface bondage</title>
<warning><title>Not Yet Written</title><para>This section has not yet been written.</para></warning>
</section>
<section id="eth_auth">
<title>Advanced: 802.1X authentication</title>
<warning><title>Not Yet Written</title><para>This section has not yet been written.</para></warning>
</section>
<section id="dhcphax">
<title>Advanced: Customising dynamic addressing</title>
<para>You may use the <varname>dhcp_<replaceable>IFACE</replaceable></varname> variable to control how DHCP is used. Valid options include:</para>
<table>
<title><varname>dhcp_<replaceable>IFACE</replaceable></varname> options</title>
<tgroup cols="2" align="left" colsep="1" rowsep="1">
<thead>
<row>
<entry>Option</entry>
<entry>Meaning</entry>
</row>
</thead>
<tbody>
<row>
<entry><code>nodns</code></entry>
<entry>Setting this option will cause the <filename>/etc/resolv.conf</filename> to remain unmodified. This allows for static DNS and nameserver configuration even with dynamic addressing.</entry>
</row>
<row>
<entry><code>nontp</code></entry>
<entry>Setting this option will cause the <filename>/etc/ntp.conf</filename> to remain unmodified, even if the DHCP server sends NTP configuration information.</entry>
</row>
</tbody>
</tgroup>
</table>
</section>
</section>
</chapter>
|