Difference between pages "Funtoo Linux Installation" and "Funtoo Linux Networking"

From Funtoo
(Difference between pages)
Jump to: navigation, search
 
 
Line 1: Line 1:
 +
<blockquote>This document explains how to configure your network settings by explaining the network configuration functionality available in Funtoo Linux. Also covered is <tt>dhcpcd 5.x</tt>, Wi-Fi (IEEE 802.11) configuration, and the OpenResolv framework.
 +
</blockquote>
 +
 
== Introduction ==
 
== Introduction ==
  
This document was written to help you install Funtoo Linux as concisely as possible, with a minimum number of distracting options regarding system configuration.  
+
Funtoo Linux has its own core network configuration system that differs somewhat from upstream network configuration systems used in [http://www.gentoo.org Gentoo Linux] and [http://roy.marples.name/projects/openrc OpenRC].
  
These docs assume you have a "PC compatible" computer system with a standard PC BIOS. Many new computers support UEFI for booting, which is a new firmware interface that replaces the old-fashioned MBR-based BIOS. If you have a system with UEFI, you will want to use this documentation along with the [[UEFI Install Guide]], which will augment these instructions and explain how to get your system to boot. You may need to change your PC BIOS settings to enable or disable UEFI booting. The [[UEFI Install Guide]] has more information on this, and steps on how to determine if your system supports UEFI.
+
In this document, I will explain the unique additions and changes to the Funtoo network configuration and show you how to use this system to configure your network.
  
We also offer a [[ZFS Install Guide]], which augment the instructions on this page for those who want to install Funtoo Linux on ZFS. If you are installing Funtoo Linux on [[Funtoo Linux Installation on ARM|ARM]] architecture, please see [[Funtoo Linux Installation on ARM]] for notable differences regarding ARM support. An experimental Funtoo Linux build also exists for [[Funtoo Linux Installation on SPARC|SPARC]] platforms. See [[Funtoo Linux Installation on SPARC]].
+
I'll also explain how to use <tt>dhcpcd 5.x</tt> for managing network interfaces on DHCP-based networks, and will also cover OpenRC stacked runlevel configuration, ''Wi-Fi'' (IEEE 802.11) configuration, and the OpenResolv framework, which is enabled in Funtoo Linux by default.
  
If you've had previous experience installing Gentoo Linux then a lot of steps will be familiar, but you should still read through as there are a few differences.
+
== A Gentle Introduction to Funtoo Network Configuration ==
  
== Installation Overview ==
+
Before I get into the technical details of configuring your network, it's important to understand that Funtoo Linux has a number of different options available to you for network configuration, with more likely to be added in the future. Each approach is different and has its own strengths and weaknesses, and this is, in my opinion, a good thing.
  
This is a basic overview of the Funtoo installation process:
+
=== The Easy (Dynamic) Way ===
  
# [[#Live CD|Download and boot the live CD of your choice]].
+
When configuring your network, one option is to skip traditional network configuration and simply rely on DHCP. This is by far the simplest method of configuring your network. If you are on a wired network, no other steps are typically required beyond enabling a DHCP client, and Funtoo Linux includes <tt>dhcpcd 5.x</tt> by default.  
# [[#Prepare Hard Disk|Prepare your disk]].
+
# [[#Creating filesystems|Create]] and [[#Mounting filesystems|mount]] filesystems.
+
# [[#Installing the Stage 3 tarball|Install the Funtoo stage tarball]] of your choice.
+
# [[#Chroot into Funtoo|Chroot into your new system]].
+
# [[#Downloading the Portage tree|Download the Portage tree]].
+
# [[#Configuring your system|Configure your system]] and [[#Configuring your network|network]].
+
# [[#Configuring and installing the Linux kernel|Install a kernel]].
+
# [[#Installing a Bootloader|Install a bootloader]].
+
# [[#Finishing Steps|Complete final steps]].
+
# [[#Restart your system|Reboot and enjoy]].
+
  
=== Live CD ===
+
==== Network Manager, Wicd ====
  
Funtoo doesn't provide an "official" Funtoo Live CD, but there are plenty of good ones out there to choose from. A great choice is the Gentoo-based [http://www.sysresccd.org/ System Rescue CD] as it contains lots of tools and utilities and supports both 32-bit and 64-bit systems.
+
If you are going to use a third party package such as [[Network Manager]] or [[Wicd]] to manage your network then you do not need to configure DHCP at all. These packages configure DHCP for you. Simply emerge the package you want to use and start using it.
  
It is also possible to install Funtoo Linux using many other Linux-based live CDs. Generally, any modern bootable Linux live CD or live USB media will work. See [[Requirements|requirements]] for an overview of what the Live Media must provide to allow a problem-free install of Funtoo Linux.
+
==== DHCP-Only Systems ====
  
To begin a Funtoo Linux installation, download System Rescue CD from:
+
If you are not planning to use a third-party package to manage your network interfaces, it is still extremely easy to set up DHCP networking, especially if you always use DHCP to connect to networks, which is common for desktops or laptops. In this scenario, we can simply enable <tt>dhcpcd</tt> to run at system startup. It will run in the background and automatically look for DHCP servers on all your network interfaces, and will attempt to lease an IP address from any DHCP servers found.
  
* Main US mirror: [http://ftp.osuosl.org/pub/funtoo/distfiles/sysresccd/ The Oregon State University Open Source Lab]
+
If this sounds like what you want to do, then add <tt>dhcpcd</tt> to your default runlevel as follows:
* Main EU mirror: [http://ftp.heanet.ie/mirrors/funtoo/distfiles/sysresccd/ HEAnet] or use your preferred live media. Insert it into your disc drive, and boot from it. If using an older version of System Rescue CD, '''be sure to select the <tt>rescue64</tt> kernel at the boot menu if you are installing a 64-bit system'''. By default, System Rescue CD used to boot in 32-bit mode though the latest version attempts to automatically detect 64-bit processors.
+
  
=== Prepare Hard Disk ===
+
<console># ##i##rc-update add dhcpcd default</console>
==== Partitions ====
+
  
Funtoo Linux fully supports traditional MBR partitions, as well as newer GPT/GUID partition formats. Funtoo Linux recommends the use of the GPT partitioning scheme, since it is newer and more flexible. Here are the various trade-offs between each partitioning scheme:
+
To enable DHCP immediately, you would follow the previous command with an <tt>rc</tt> command, which would start the <tt>dhcpcd</tt> client you just added:
  
===== GPT Partitions =====
+
<console># ##i##rc</console>
  
* Newer, preferred format for Linux systems
+
If you're on a wired network and have the necessary drivers in your kernel, then this should get you going. For wireless networks, more steps are required to utilize your wireless hardware to associate with an access point, which will be covered later in this document.
* Supports 2 TB+ hard drives for booting
+
* Supports hundreds of partitions per disk of any size
+
* Requires legacy BIOS boot partition (~32 MB) to be created if system does not use EFI
+
* Requires bootloader with support for GPT such as GRUB 2, EXTLINUX, or a patched version of GRUB Legacy
+
  
===== MBR Partitions =====
+
===== Tweaking Dhcpcd =====
  
* Legacy, DOS partitioning scheme
+
For now, it's important to note that <tt>dhcpcd 5.x</tt> will manage ''all'' available network interfaces by default. If you want to run a DHCP client on ''all but one'' interface, or some other subset of interfaces, you can add the appropriate <tt>denyinterfaces</tt> or <tt>allowinterfaces</tt> [[glob pattern]] to <tt>/etc/dhcpcd.conf</tt>:
* Only 4 primary partitions per disk; after that, you must use "logical" partitions
+
* Does not support 2 TB+ disks for booting
+
* Compatible with certain problematic systems (such as the HP ProBook 4520)
+
* Dual-boot with Windows for BIOS systems (Windows handle GPT only on true EFI systems, whatever version it is)
+
* Multiple boot loader options, e.g. GRUB 2, GRUB Legacy, lilo
+
  
{{fancyimportant|If you plan to use partitions of 2 TB or greater, you ''must'' partition using the GPT/GUID format. Also note that there are small percentage of PCs that will not boot properly with GPT. For these systems, using MBR partitions or a primary drive with an MBR partition may be required in order to boot.}}
+
<pre>
 +
# manage all interfaces but eth0 with dhcpcd
 +
denyinterfaces eth0
 +
</pre>
  
==== Partitioning Using gdisk ====
+
This can also be accomplished by modifying <tt>/etc/init.d/dhcpcd</tt> directly and adding <tt>-Z ''ifglob''</tt> or <tt>-z ''ifglob''</tt> (the equivalent command-line parameters) to <tt>command_args</tt>.
  
===== Notes Before We Begin =====
+
==== Using Funtoo Scripts for DHCP ====
  
These install instructions assume you are installing Funtoo Linux to an empty hard disk using GUID partition tables (GPT). If you are installing Funtoo Linux on a machine where another OS is installed, or there is an existing Linux distribution on your system that you want to keep, then you will need to adapt these instructions to suit your needs.
+
You can also use the Funtoo Linux networking scripts to start a DHCP client just on a specific interface. This approach is best if you are planning to also do some advanced bridging, bonding or VLAN configuration on your machine along with DHCP, since you will be using the Funtoo Linux networking scripts for that too.  
  
If you are going to create a legacy MBR partition table instead of GUID/GPT, you will use the <tt>fdisk</tt> command instead of <tt>gdisk</tt>, and you will not need to create the GRUB boot loader partition. See the table under [[#Partitioning Recommendations|Partitioning Recommendations]], in particular the
+
To use this variant approach, ''don't'' enable <tt>/etc/init.d/dhcpcd</tt> directly. Instead, use the Funtoo Linux <tt>dhcpcd</tt> template which will start dhcpcd on only one interface. Below, you will see the steps to do this. This is very similar to how we set up advanced network interfaces, which will be covered later in this documentation:
'''MBR Block Device (<tt>fdisk</tt>)''' and '''MBR Code''' columns. <tt>fdisk</tt> works just like <tt>gdisk</tt>, but creates legacy MBR partition tables instead of the newer GPT/GUID partition tables.
+
  
Advanced users may be interested in the following topics:
+
<console>
 +
# ##i##cd /etc/init.d
 +
# ##i##ln -s netif.tmpl netif.eth0
 +
# ##i##rc-update add netif.eth0 default
 +
# ##i##echo template=dhcpcd > /etc/conf.d/netif.eth0
 +
# ##i##rc
 +
</console>
  
* [[GUID Booting Guide]]
+
The last command, <tt>rc</tt>, causes <tt>netif.eth0</tt> to be started.
* [[Rootfs over encrypted lvm]]
+
* [[Rootfs over encrypted lvm over raid-1 on GPT]]
+
* '''NEW!''' '''[[ZFS Install Guide]] (Also contains instructions for Rootfs over Encrypted ZFS!)'''
+
  
===== Using gdisk =====
+
=== Server Network Configuration ===
  
The first step after booting SystemRescueCd is to use <tt>gdisk</tt> to create GPT (also known as GUID) partitions, specifying the disk you want to use, which is typically <tt>/dev/sda</tt>, the first disk in the system:
+
For servers and advanced networking scenarios, Funtoo Linux offers its own modular, template-based network configuration system. This system offers a lot of flexibility for configuring network interfaces, essentially serving as a &quot;network interface construction kit.&quot; This system can be used by itself, or even combined with <tt>dhcpcd</tt>, as shown in the previous section.
  
<console># ##i##gdisk /dev/sda</console>
+
Here are the key components of the template-based network configuration system:
You should find <tt>gdisk</tt> very similar to <tt>fdisk</tt>. Here is the partition table we want to end up with:
+
  
<console>Command (? for help): ##i##p
+
;<tt>/etc/init.d/netif.lo</tt>: An init script that configures the localhost interface. This script is always enabled and is part of the boot process.
Disk /dev/sda: 234441648 sectors, 111.8 GiB
+
;<tt>/etc/netif.d</tt>: This is a directory that contains various network configuration templates. Each of these templates is focused on configuring a particular type of network interface, such as a general static IP-based interface, a bridge interface, a bond interface, etc.
Logical sector size: 512 bytes
+
;<tt>/etc/init.d/netif.tmpl</tt>: This is the master init script for the template-based network configuration system. New interfaces are added to your system by creating '''symbolic links''' to this file in <tt>/etc/init.d</tt>.
Disk identifier (GUID): A4E5208A-CED3-4263-BB25-7147DC426931
+
Partition table holds up to 128 entries
+
First usable sector is 34, last usable sector is 234441614
+
Partitions will be aligned on 2048-sector boundaries
+
Total free space is 2014 sectors (1007.0 KiB)
+
  
Number  Start (sector)    End (sector)  Size      Code  Name
+
So, if you wanted to use this system to configure <tt>eth0</tt> with a static IP address, you would create a <tt>netif.eth0</tt> symlink to <tt>netif.tmpl</tt> as follows:
  1            2048          206847  500.0 MiB  8300  Linux filesystem
+
  2          206848          272383  32.0 MiB    EF02  BIOS boot partition
+
  3          272384        8660991  4.0 GiB    8200  Linux swap
+
  4        8660992      234441614  107.7 GiB  8300  Linux filesystem
+
  
Command (? for help): </console>
+
<console># ##i##cd /etc/init.d
 +
# ##i##ln -s netif.tmpl netif.eth0</console>
 +
Then, you would create an <tt>/etc/conf.d/netif.eth0</tt> configuration file that would specify which template to use from the <tt>/etc/netif.d</tt> directory:
  
Above, you'll see that we have a 500 MiB boot partition, a 32 MiB "BIOS boot partition" (also known as the GRUB boot loader partition), 4 GiB of swap, and the remaining disk used by a 107.7 GiB root partition.
+
<pre>
 +
template="interface"
 +
ipaddr="10.0.1.200/24"
 +
gateway="10.0.1.1"
 +
nameservers="10.0.1.1 10.0.1.2"
 +
domain="funtoo.org"
 +
</pre>
  
===== For new <tt>gdisk</tt> users =====
+
To complete our static IP network configuration we would need to:
  
These partitions were created using the "<tt>n</tt>" command from within <tt>gdisk</tt>. The <tt>gdisk</tt> commands to create the partition table above are as follows. Adapt sizes as necessary, although these defaults will work for most users. The partition codes entered below can be found in the [[#Partitioning Recommendations|Partitioning Recommendations]] table below, in the GPT Code column.
+
<console># ##i##rc-update add netif.eth0 default</console>
 +
When configuring your own static network interface, one of <tt>ipaddr</tt> or <tt>ipaddrs</tt> is required and should specify the IP address(es) to configure for this interface, in &quot;a.b.c.d/netmask&quot; format. Optional parameters include <tt>gateway</tt>, which defines a default gateway for your entire network, and if set should specify the gateway's IP address. In addition, <tt>domain</tt> and <tt>nameservers</tt> (space-separated if more than one) can be used to specify DNS information for this interface.
  
Within <tt>gdisk</tt>, follow these steps:
+
=== Configuration Variables ===
  
'''Create a new empty partition table''' (This ''will'' erase all data on the disk when saved):
+
==== Interface Variables ====
  
<console>
+
The <tt>ipaddr</tt> and <tt>ipaddrs</tt> variables are supported by the <tt>interface</tt> and <tt>bridge</tt> templates, and are used to specify a single or multiple  IPv4 or IPv6 address(es) for the interface. IP addresses should be specified in 'IP/netmask' format, such as <tt>10.0.0.1/24</tt>. Multiple IP addresses can be specified delimited by whitespace:
Command: ##i##o ↵
+
This option deletes all partitions and creates a new protective MBR.
+
Proceed? (Y/N): ##i##y ↵
+
</console>
+
  
'''Create Partition 1''' (boot):
+
<pre>ipaddrs=&quot;10.0.0.1/24 10.0.0.2/24&quot;</pre>
  
<console>
+
===== Broadcast Address =====
Command: ##i##n ↵
+
Partition Number: ##i##1 ↵
+
First sector: ##i##↵
+
Last sector: ##i##+500M ↵
+
Hex Code: ##i##↵
+
</console>
+
  
'''Create Partition 2''' (GRUB):
+
By default, a broadcast address will be calculated based on the IP address and network mask. If you need to manually specify a broadcast address, use the following format for your IP address:
  
<console>
+
<pre>
Command: ##i##n ↵
+
ipaddrs="10.0.0.1/24;broadcast=10.0.1.255 10.0.0.2/24"
Partition Number: ##i##2
+
</pre>
First sector: ##i##↵
+
Last sector: ##i##+32M ↵
+
Hex Code: ##i##EF02 ↵
+
</console>
+
  
'''Create Partition 3''' (swap):
+
===== Not Specifying An Address =====
  
<console>
+
Note that in some cases, you may choose to '''not''' specify <tt>ipaddr</tt> or <tt>ipaddrs</tt> for a <tt>bridge</tt> template. That is allowed. If you don't want to specify an IP address for a regular interface, you can choose to use the <tt>interface</tt> template without an IP address specified in the config, or use the <tt>interface-noip</tt> template instead, for the sake of clarity.
Command: ##i##n ↵
+
Partition Number: ##i##3 ↵
+
First sector: ##i##↵
+
Last sector: ##i##+4G ↵
+
Hex Code: ##i##8200 ↵
+
</console>
+
  
'''Create Partition 4''' (root):
+
===== Viewing All Configured IP Addresses =====
  
<console>
+
Also note that if you specify multiple IPv4 addresses, <tt>ifconfig</tt> will only show the first IP address. To view all IP addresses associated with the interface, use the <tt>ip addr show</tt> command.
Command: ##i##n ↵
+
Partition Number: ##i##4 ↵
+
First sector: ##i##↵
+
Last sector: ##i##↵##!i## (for rest of disk)
+
Hex Code: ##i##↵
+
</console>
+
  
Along the way, you can type "<tt>p</tt>" and hit Enter to view your current partition table. If you make a mistake, you can type "<tt>d</tt>" to delete an existing partition that you created. When you are satisfied with your partition setup, type "<tt>w</tt>" to write your configuration to disk:
+
=== General Variables ===
  
'''Write Partition Table To Disk''':
+
The following variables are enabled by default for all network scripts, and if specified will trigger a corresponding configuration action:
  
<console>
+
;<tt>nameservers</tt>: Set DNS nameservers using OpenResolv. Specify multiple IPv4 or IPv6 nameservers like this: &quot;1.2.3.4 1.2.3.5 1.2.3.6&quot;. Please note that OpenResolv treats <tt>127.0.0.1</tt> specially, and it indicates that you are running a local name resolver like <tt>dnsmasq</tt> or <tt>bind</tt>. OpenResolv will ignore all other name servers specified alongside <tt>127.0.0.1</tt>. See <tt>man resolvconf</tt> and <tt>man resolvconf.conf</tt> for additional setup information.
Command: ##i##w ↵
+
;<tt>search</tt>: Set DNS search information using OpenResolv.
Do you want to proceed? (Y/N): ##i##Y ↵
+
;<tt>domain</tt>: Set DNS domain using OpenResolv.
</console>
+
;<tt>gateway</tt>: Define a default IPv4 gateway on this interface.
 +
;<tt>gateway6</tt>: Define a default IPv6 gateway on this interface.
 +
;<tt>route</tt>: Specify a semi-colon delimited list of IPv4 routes to apply when this interface is brought up. Will be appended to <tt>ip -4 route add</tt>.
 +
;<tt>route6</tt>: Specify a semi-colon delimited list of IPv6 routes to apply when this interface is brought up. Will be appended to <tt>ip -6 route add</tt>.
 +
;<tt>mtu</tt>: Set Maximum Transmit Unit for the interface
  
The partition table will now be written to disk and <tt>gdisk</tt> will close.
 
  
Now, your GPT/GUID partitions have been created, and will show up as the following ''block devices'' under Linux:
 
  
* <tt>/dev/sda1</tt>, which will be used to hold the <tt>/boot</tt> filesystem,
+
==== VLAN Variables ====
* <tt>/dev/sda2</tt>, which will be used directly by the new GRUB,
+
* <tt>/dev/sda3</tt>, which will be used for swap space, and
+
* <tt>/dev/sda4</tt>, which will hold your root filesystem.
+
  
===== For Previous fdisk users =====
+
VLAN support is enabled by default for all network configuration scripts. If a network script has a name in the format <tt>netif.ethX.Y</tt>, then it is assumed to be a VLAN interface referencing trunk <tt>ethX</tt> and VLAN ID <tt>Y</tt>. If you desire a custom name for your VLAN interface, you can name your interface whatever you'd like and specify the following variables in your interface config:
  
If you have installed Gentoo Linux before, the one thing that is likely new to you here is the GRUB boot loader partition, which is listed as "BIOS boot partition" within <tt>gdisk</tt>. This partition is required for GRUB 2 to boot GPT/GUID boot disks. What is it? In GRUB-speak, this partition is essentially the location of the meat of GRUB's boot loading code. If you've used GRUB Legacy in the past, this partition is where the new GRUB stores the equivalent of the <tt>stage1_5</tt> and <tt>stage2</tt> files in legacy GRUB. Since GPT-based partition tables have less dead space at the beginning of the disk than their MBR equivalents, an explicitly defined partition of code <tt>EF02</tt> is required to hold the guts of the boot loader.
+
;<tt>trunk</tt>: VLAN trunk interface, e.g. &quot;eth0&quot;
 +
;<tt>vlan</tt>: VLAN id, e.g. &quot;32&quot;
  
In all other respects, the partition table is similar to that which you might create for an MBR-based disk during a Gentoo Linux installation. We have a boot and a root partition with code <tt>0700</tt>, and a Linux swap partition with code <tt>8200</tt>.
+
==== Bridge / Tap Variables ====
  
===== Partitioning Recommendations =====
+
The following variables for configuring a functional bridge interface with optional tap interfaces:
  
Below are our partitioning recommendations in table form. For GPT-based partitions, use the GPT Block Device and GPT Code columns with <tt>gdisk</tt>. For legacy MBR-based partitions, use the MBR Block Device and MBR code columns with <tt>fdisk</tt>:
+
;<tt>slaves</tt>: Set slave interfaces of this interface (for bridges, etc.) All slaves will automatically be depended upon, and will also automatically have their <tt>mtu</tt> set to that of the current interface, if an <tt>mtu</tt> is specified for the current interface. This setting is required for the <tt>bond</tt> template and optional for the <tt>bridge</tt> template.
 +
;<tt>stp</tt>: Enables Spanning Tree Protocol on a bridge interface like this &quot;stp=on&quot;
 +
;<tt>forwarding</tt>: Enables forwarding on a bridge interface by calling sysctl; as this interface does not exist when sysctl is called by init, we do it here. If this is disabled, your bridge will not forward traffic back out onto the network. useage: &quot;forwarding=1&quot;
 +
;<tt>mac_addr</tt>: Sets a MAC address on a tap interface. This is usefull for avoiding layer2 address collisions when using large numbers of TUN interfaces (KVM, openVPN, ect)
  
{| {{table}}
+
=== OpenResolv and resolv.conf ===
!Partition
+
!Size
+
!MBR Block Device (<tt>fdisk</tt>)
+
!GPT Block Device (<tt>gdisk</tt>)
+
!Filesystem
+
!MBR Code
+
!GPT Code
+
|-
+
|<tt>/boot</tt>
+
|500 MB
+
|<tt>/dev/sda1</tt>
+
|<tt>/dev/sda1</tt>
+
|ext2
+
|83
+
|8300
+
|-
+
|GRUB boot loader partition
+
|32 MB
+
| ''not required for MBR''
+
|<tt>/dev/sda2</tt>
+
|For GPT/GUID only, skip for MBR - no filesystem.
+
|''N/A''
+
|EF02
+
|-
+
|swap
+
|2x RAM for low-memory systems and production servers; otherwise 2GB.
+
|<tt>/dev/sda2</tt>
+
|<tt>/dev/sda3</tt>
+
|swap (default)
+
|82
+
|8200
+
|-
+
|<tt>/</tt> (root)
+
|Rest of the disk, minimum of 10GB.
+
|<tt>/dev/sda3</tt>
+
|<tt>/dev/sda4</tt>
+
|XFS recommended, alternatively ext4
+
|83
+
|8300
+
|-
+
|<tt>/home</tt> (optional)
+
|User storage and media. Typically most of the disk.
+
|<tt>/dev/sda4</tt> (if created)
+
|<tt>/dev/sda5</tt> (if created)
+
|XFS recommended, alternatively ext4
+
|83
+
|8300
+
|-
+
| LVM (optional)
+
| If you want to create an LVM volume.
+
| <tt>/dev/sda4</tt> (PV, if created)
+
| <tt>/dev/sda5</tt> (PV, if created)
+
| LVM PV
+
| 8E
+
| 8E00
+
|}
+
  
==== Creating filesystems ====
+
OpenResolv will be used to set DNS information provided by the <tt>nameservers</tt>, <tt>domain</tt> and <tt>search</tt> variables when an interface is brought up. The OpenResolv framework will add entries to <tt>/etc/resolv.conf</tt>, and will also handle removing these entries when the interface is brought down. This way, <tt>/etc/resolv.conf</tt> should always contain current information and should not need to be manually edited by the system administrator. <tt>dhcpcd</tt> will use OpenResolv for updating system DNS information as well.
  
Before your newly-created partitions can be used, the block devices need to be initialized with filesystem ''metadata''. This process is known as ''creating a filesystem'' on the block devices. After filesystems are created on the block devices, they can be mounted and used to store files.
+
=== Network-Dependent Services ===
  
You will not create a filesystem on your swap partition, but will initialize it using the <tt>mkswap</tt> command so that it can be used as disk-based virtual memory. Then we'll run the <tt>swapon</tt> command to make your newly-initialized swap space active within the live CD environment, in case it is needed during the rest of the install process.
+
One important difference between Gentoo Linux and Funtoo Linux is that, in Funtoo Linux, network-dependent services only strictly depend on <tt>netif.lo</tt>. This means that if another network service requires an interface to be up, such as <tt>samba</tt> requiring <tt>eth0</tt>, then the system administrator must specify this relationship by adding the following line to <tt>/etc/conf.d/samba</tt>:
  
Note that we will not create a filesystem on the GRUB boot loader partition, as GRUB writes binary data directly to that partition when the boot loader is installed, which we'll do later.
+
<pre>rc_need=&quot;netif.eth0&quot;</pre>
 +
This will have the effect of ensuring that <tt>netif.eth0</tt> is started prior to <tt>samba</tt> and that <tt>samba</tt> is stopped prior to stopping <tt>netif.eth0</tt>.
  
You can see the commands you will need to type below. Like the rest of this document, it assumes that you are using a GPT partitioning scheme. If you are using MBR, your root filesystem will likely be created on <tt>/dev/sda3</tt> instead and you will need to adjust the target block devices. If you are following our recommendations, then simply do this:
+
Many network services, especially those that listen on all network intefaces, don't need an <tt>rc_need</tt> line in order to function properly. Avoiding the use of <tt>rc_need</tt> when required will optimize boot times and allow more network services to remain available when network interfaces are brought up and down by the system administrator.
  
'''We generally recommend XFS for root filesystems, although ext4 is also a good choice.''' This tutorial assumes the use of XFS. If you want to use ext4, then be sure that your <tt>/etc/fstab</tt> file reflects this.
+
=== Multiple Network Configurations ===
  
{{fancywarning|1=
+
For information on how to have multiple, independent network configurations, please see [[Stacked Runlevels]].
Please use ext4 exclusively when deploying an OpenVZ host. The Parallels development team tests extensively with ext4, and modern versions of <tt>openvz-rhel6-stable</tt> are '''not''' compatible with XFS, and you may experience kernel bugs.
+
}}
+
  
'''To use XFS as your root filesystem:'''
+
=== Alternate Configs ===
 +
If you need to run the same service with different configuration parameters depending upon runlevel, then you'll be happy to know that you can specify runlevel-specific conf.d files by appending a <tt>.
 +
&lt;runlevel&gt;</tt> suffix. In this particular example, we could imagine a situation where we had two child runlevels named <tt>home</tt> and <tt>work</tt>:
  
<console>
+
<pre>/etc/conf.d/netif.eth0.home
# ##i##mke2fs -t ext2 /dev/sda1
+
/etc/conf.d/netif.eth0.work</pre>Note that this feature works for all init scripts, not just network configuration scripts.
# ##i##mkfs.xfs /dev/sda4
+
# ##i##mkswap /dev/sda3
+
# ##i##swapon /dev/sda3
+
</console>
+
  
'''To use ext4 as your root filesystem:'''
+
=== Interface Renaming ===
  
<console>
+
Funtoo network scripts now support interface renaming, so you can create an interface called <tt>lan</tt> if you would like. To do this, simply specify the MAC address of the interface you would like to rename using the <tt>macaddr</tt> variable:
# ##i##mke2fs -t ext2 /dev/sda1
+
<pre>macaddr=&quot;00:15:17:19:b6:a3&quot;</pre>If this MAC address is part of the <tt>netif.lan</tt> configuration file, then when this interface starts, whatever interface currently has the MAC address of 00:15:17:19:b6:a3 (i.e. <tt>eth5</tt>) will be renamed to <tt>lan</tt> prior to the interface being brought up, and will show up in <tt>ifconfig</tt> and <tt>ip</tt> commands as being an interface named <tt>lan</tt>.
# ##i##mkfs.ext4 /dev/sda4
+
# ##i##mkswap /dev/sda3
+
# ##i##swapon /dev/sda3
+
</console>
+
  
==== Mounting filesystems ====
+
=== Basic VLAN Configuration ===
  
Mount the newly-created filesystems as follows, creating <tt>/mnt/funtoo</tt> as the installation mount point:
+
The standard <tt>interface</tt> template supports VLANs. To use VLAN support, first ensure that your kernel was compiled with VLAN support (the module name is <tt>8021q</tt>) :
  
 
<console>
 
<console>
# ##i##mkdir /mnt/funtoo
+
# ##i##grep CONFIG_VLAN /usr/src/linux/.config
# ##i##mount /dev/sda4 /mnt/funtoo
+
CONFIG_VLAN_8021Q=m
# ##i##mkdir /mnt/funtoo/boot
+
CONFIG_VLAN_8021Q_GVRP=y
# ##i##mount /dev/sda1 /mnt/funtoo/boot
+
 
</console>
 
</console>
  
Optionally, if you have a separate filesystem for <tt>/home</tt> or anything else:
+
Then, configure the trunk interface using the <tt>interface-noip</tt> template. Assuming <tt>eth1</tt> is trunked, you would create the file <tt>/etc/conf.d/netif.eth1</tt> with the following contents:
  
<console>
+
<pre>template=&quot;interface-noip&quot;</pre>
# ##i##mkdir /mnt/funtoo/home
+
# ##i##mount /dev/sda5 /mnt/funtoo/home
+
</console>
+
  
If you have <tt>/tmp</tt> or <tt>/var/tmp</tt> on a separate filesystem, be sure to change the permissions of the mount point to be globally-writeable after mounting, as follows:
+
Then, create a network interface symlink for the trunk and add it to your default runlevel:
  
 
<console>
 
<console>
# ##i##chmod 1777 /mnt/funtoo/tmp
+
# ##i##cd /etc/init.d
 +
# ##i##ln -s netif.tmpl netif.eth1
 +
# ##i##rc-update add netif.eth1 default
 
</console>
 
</console>
  
=== Installing the Stage 3 tarball ===
+
Now, assuming you wanted to configure a VLAN of 32, you would create a config file named <tt>/etc/conf.d/netif.eth1.32</tt> that looks something like this:
==== Stage 3 tarball ====
+
  
After creating filesystems, the next step is downloading the initial Stage 3 tarball. The Stage 3 is a pre-compiled system used as a starting point to install Funtoo Linux. Visit the [[Download]] page and copy the URL to the Stage 3 tarball you want to use. We will download it soon.
+
<pre>
 +
template=&quot;interface&quot;
 +
ipaddr=&quot;1.2.3.4/24&quot;
 +
gateway=&quot;1.2.3.1&quot;# etc...
 +
</pre>
  
{{fancyimportant|If your system's date and time are too far off (typically by months or years,) then it may prevent Portage from properly downloading source tarballs. This is because some of our sources are downloaded via HTTPS, which use SSL certificates and are marked with an activation and expiration date.}}
+
Then, create a VLAN network interface symlink and add it to your default runlevel:
 
+
Now is a good time to verify the date and time are correctly set to UTC. Use the <tt>date</tt> command to verify the date and time:
+
  
 
<console>
 
<console>
# ##i##date
+
# ##i##cd /etc/init.d
Fri Jul 15 19:47:18 UTC 2011
+
# ##i##ln -s netif.tmpl netif.eth1.32
 +
# ##i##rc-update add netif.eth1.32 default
 
</console>
 
</console>
  
If the date and/or time need to be corrected, do so using <tt>date MMDDhhmmYYYY</tt>, keeping in mind <tt>hhmm</tt> are in 24-hour format. The example below changes the date and time to "July 16th, 2011 @ 8:00PM" UTC:
+
The Funtoo network configuration scripts will automatically recognize the filename <tt>netif.eth1.32</tt> as being VLAN 32 of trunk interface <tt>netif.eth1</tt>.
  
<console>
+
When the VLAN interface is brought up, it will be named <tt>eth1.32</tt>.
# ##i##date 071620002011
+
Fri Jul 16 20:00:00 UTC 2011
+
</console>
+
  
Once you are in your Funtoo Linux root filesystem, use <tt>wget</tt> to download the Stage 3 tarball you have chosen from the [[Download]] page to use as the basis for your new Funtoo Linux system. It should be saved to the <tt>/mnt/funtoo</tt> directory as follows:
+
=== Custom VLAN Names ===
  
<console># ##i##cd /mnt/funtoo
+
However, sometimes you may want to turn off automatic file-based VLAN naming and give your VLAN interface a custom name, such as <tt>mgmt</tt>. To do this, you would set up the trunk interface in the exact same way as described above, but instead of creating a <tt>netif.eth1.32</tt> interface, you would create a <tt>netif.mgmt</tt> interface, and specify <tt>vlan</tt> and <tt>trunk</tt> in the <tt>/etc/conf.d/netif.mgmt</tt> config file, as follows:
# ##i##wget http://ftp.osuosl.org/pub/funtoo/funtoo-current/x86-64bit/generic_64/stage3-latest.tar.xz
+
</console>
+
  
 +
<pre>template=&quot;interface&quot;
 +
vlan=&quot;32&quot;
 +
trunk=&quot;eth1&quot;
 +
ipaddr=&quot;1.2.3.4/24&quot;
 +
gateway=&quot;1.2.3.1&quot;
 +
# etc...</pre>
 +
When you specify <tt>trunk</tt> and <tt>vlan</tt> in the interface config file, filename-based auto-detecting of VLAN ID and trunk is disabled. Both <tt>trunk</tt> and <tt>vlan</tt> must be specified -- you can't specify just one.
  
Note that 64-bit systems can run 32-bit or 64-bit stages, but 32-bit systems can only run 32-bit stages. Make sure that you select a Stage 3 build that is appropriate for your CPU. If you are not certain, it is a safe bet to choose the <tt>generic_64</tt> or <tt>generic_32</tt> stage. Consult the [[Download]] page for more information.
+
Then you would simply create a VLAN network interface symlink for <tt>netif.mgmt</tt>:
  
Once the stage is downloaded, extract the contents with the following command, substituting in the actual name of your stage 3 tarball:
+
<console># ##i##cd /etc/init.d
<console>
+
# ##i##ln -s netif.tmpl netif.mgmt
# ##i##tar xpf stage3-latest.tar.xz
+
# ##i##rc-update add netif.mgmt default</console>
</console>
+
When the VLAN interface is brought up, it will be named <tt>mgmt</tt>.
  
{{fancyimportant|It is very important to use <tt>tar</tt>'s "<tt>p</tt>" option when extracting the Stage 3 tarball - it tells <tt>tar</tt> to ''preserve'' any permissions and ownership that exist within the archive. Without this option, your Funtoo Linux filesystem permissions will be incorrect.}}
+
=== Bonding Configuration ===
  
=== Chroot into Funtoo ===
+
Bonding allows you to aggregate multiple network interfaces into a single logical network interface, allowing for benefits in throughput as well as resiliency in the case that an individual interface may go down. This example shows how you would create a bonding interface (<tt>mybond</tt>) with a simple static ip setup, containing two slave devices (<tt>eth0</tt> and <tt>eth1</tt>).
Before chrooting into your new system, there's a few things that need to be done first. You will need to mount /proc and /dev inside your new system. Use the following commands:
+
<console>
+
# ##i##cd /mnt/funtoo
+
# ##i##mount -t proc none proc
+
# ##i##mount --rbind /sys sys
+
# ##i##mount --rbind /dev dev
+
</console>
+
  
You'll also want to copy over <tt>resolv.conf</tt> in order to have proper DNS name resolution from inside the chroot:
+
First, ensure that your kernel is configured to support bonding (the module name is <tt>bonding</tt>) :
<console>
+
# ##i##cp /etc/resolv.conf etc
+
</console>
+
 
+
Now you can chroot into your new system. Use <tt>env</tt> before <tt>chroot</tt> to ensure that no environment variables from the installation media are used by your new system:
+
  
 
<console>
 
<console>
# ##i##env -i HOME=/root TERM=$TERM chroot . bash -l
+
$ ##i##grep CONFIG_BONDING /usr/src/linux/.config
 +
CONFIG_BONDING=m
 
</console>
 
</console>
  
{{fancynote|Users of live CDs with 64-bit kernels: Some software may use <tt>uname -r</tt> to check whether the system is 32 or 64-bit. You may want append linux32 to the chroot command as a workaround, but it's generally not needed.}}
+
You'l want to ensure that CONFIG_BONDING is set to "m" or "y". You can find this kernel configuration option tucked under "Device Drivers" -> "Network Device Support" -> "Bonding driver support".
{{fancyimportant|If you receive the error "<tt>chroot: failed to run command `/bin/bash': Exec format error</tt>", it is probably because you are running a 32-bit kernel and trying to execute 64-bit code. SystemRescueCd boots with a 32-bit kernel by default.}}
+
Be sure that ifenslave is emerged:
  
It's also a good idea to change the default command prompt while inside the chroot. This will avoid confusion if you have to change terminals. Use this command:
 
 
<console>
 
<console>
# ##i##export PS1="(chroot) $PS1"
+
emerge ifenslave
 
</console>
 
</console>
 
+
Once bonding is enabled in the kernel, you will need to choose at least two devices to bond together. These will be set up as "slave" interfaces with no IP address.
Congratulations! You are now chrooted inside a Funtoo Linux system. Now it's time to get Funtoo Linux properly configured so that Funtoo Linux will boot successfully when your system is restarted.
+
 
+
=== Downloading the Portage tree ===
+
 
+
{{fancynote|For an alternative way to do this, see [[Installing Portage From Snapshot]].}}
+
Now it's time to install a copy of the Portage repository, which contains package scripts (ebuilds) that tell portage how to build and install thousands of different software packages. To create the Portage repository, simply run <tt>emerge --sync</tt> from within the chroot. This will automatically clone the portage tree from [http://github.com/ GitHub]:
+
  
 
<console>
 
<console>
(chroot) # ##i##emerge --sync
+
# ##i##cd /etc/init.d/
 +
# ##i##ln -s netif.tmpl netif.eth0
 +
# ##i##ln -s netif.tmpl netif.eth1
 
</console>
 
</console>
  
{{fancyimportant|If you receive the error with initial <tt>emerge --sync</tt> due to git protocol restrictions, change <tt>SYNC</tt> variable in <tt>/etc/portage/make.conf</tt>}}
+
Then, configure the slave interfaces by creating <tt>/etc/conf.d/netif.eth0</tt> and <tt>/etc/conf.d/netif.eth1</tt> with the following contents:
<pre>
+
SYNC="https://github.com/funtoo/ports-2012.git"
+
</pre>
+
 
+
 
+
=== Configuring your system ===
+
As is expected from a Linux distribution, Funtoo Linux has its share of configuration files. The one file you are absolutely required to edit in order to ensure that Funtoo Linux boots successfully is <tt>/etc/fstab</tt>. The others are optional. Here are a list of files that you should consider editing:
+
 
+
{| {{table}}
+
!File
+
!Do I need to change it?
+
!Description
+
|-
+
|<tt>/etc/fstab</tt>
+
|'''YES - required'''
+
|Mount points for all filesystems to be used at boot time. This file must reflect your disk partition setup. We'll guide you through modifying this file below.
+
|-
+
|<tt>/etc/localtime</tt>
+
|''Maybe - recommended''
+
|Your timezone, which will default to UTC if not set. This should be a symbolic link to something located under /usr/share/zoneinfo (e.g. /usr/share/zoneinfo/America/Montreal)
+
|-
+
|<tt>/etc/make.conf<br/>/etc/portage/make.conf&nbsp;(new&nbsp;location)</tt>
+
|''Maybe - recommended''
+
|Parameters used by gcc (compiler), portage, and make. It's a good idea to set MAKEOPTS. This is covered later in this document.
+
|-
+
|<tt>/etc/conf.d/hostname</tt>
+
|''Maybe - recommended''
+
|Used to set system hostname. Set to the fully-qualified (with dots) name. Defaults to <tt>localhost</tt> if not set.
+
|-
+
|<tt>/etc/hosts</tt>
+
|''No''
+
| You no longer need to manually set the hostname in this file. This file is automatically generated by <tt>/etc/init.d/hostname</tt>.
+
|-
+
|<tt>/etc/conf.d/keymaps</tt>
+
|Optional
+
|Keyboard mapping configuration file (for console pseudo-terminals). Set if you have a non-US keyboard. See [[Funtoo Linux Localization]].
+
|-
+
|<tt>/etc/conf.d/hwclock</tt>
+
|Optional
+
|How the time of the battery-backed hardware clock of the system is interpreted (UTC or local time). Linux uses the battery-backed hardware clock to initialize the system clock when the system is booted.
+
|-
+
|<tt>/etc/conf.d/modules</tt>
+
|Optional
+
|Kernel modules to load automatically at system startup. Typically not required. See [[Additional Kernel Resources]] for more info.
+
|-
+
|<tt>profiles</tt>
+
|Optional
+
|Some useful portage settings that may help speed up intial configuration.
+
|}
+
 
+
If you're installing an English version of Funtoo Linux, you're in luck as most of the configuration files can be used as-is. If you're installing for another locale, don't worry. We will walk you through the necessary configuration steps on the [[Funtoo Linux Localization]] page, and if needed, there's always plenty of friendly, helpful support. (See [[#Community portal|Community]])
+
 
+
Let's go ahead and see what we have to do. Use <tt>nano -w <name_of_file></tt> to edit files -- the "<tt>-w</tt>" disables word-wrapping, which is handy when editing configuration files. You can copy and paste from the examples.
+
 
+
{{fancywarning|It's important to edit your <tt>/etc/fstab</tt> file before you reboot! You will need to modify both the "fs" and "type" columns to match the settings for your partitions and filesystems that you created with <tt>gdisk</tt> or <tt>fdisk</tt>. Skipping this step may prevent Funtoo Linux from booting successfully.}}
+
 
+
==== /etc/fstab ====
+
 
+
<tt>/etc/fstab</tt> is used by the <tt>mount</tt> command which is ran when your system boots. Statements of this file inform <tt>mount</tt> about partitions to be mounted and how they are mounted. In order for the system to boot properly, you must edit <tt>/etc/fstab</tt> and ensure that it reflects the partition configuration you used earlier:
+
 
+
<console>
+
(chroot) # ##i##nano -w /etc/fstab
+
</console>
+
 
+
You can use arrow keys to move around and hit Control-X to exit. If you want to save your changes, type "<tt>Y</tt>" when asked if you want to save the modified buffer, or hit Control-O before closing <tt>nano</tt>. Otherwise your changes will be discarded.
+
  
 
<pre>
 
<pre>
# The root filesystem should have a pass number of either 0 or 1.
+
template="interface-noip"
# All other filesystems should have a pass number of 0 or greater than 1.
+
#
+
# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.
+
#
+
# See the manpage fstab(5) for more information.
+
#
+
# <fs>     <mountpoint>  <type>  <opts>        <dump/pass>
+
 
+
/dev/sda1    /boot        ext2    noatime        1 2
+
/dev/sda3    none          swap    sw            0 0
+
/dev/sda4    /            ext4    noatime        0 1
+
#/dev/cdrom  /mnt/cdrom    auto    noauto,ro      0 0
+
 
</pre>
 
</pre>
  
==== /etc/localtime ====
+
Now, we will create the bond interface and make <tt>netif.eth0</tt> and <tt>netif.eth1</tt> slaves of this interface. Note that our bond interface can have any name. To demonstrate this, we will give it the name of "mybond" below:
 
+
<tt>/etc/localtime</tt> is used to specify the timezone that your machine is in, and defaults to UTC. If you would like your Funtoo Linux system to use local time, you should replace <tt>/etc/localtime</tt> with a symbolic link to the timezone that you wish to use.  
+
  
 
<console>
 
<console>
(chroot) # ##i##ln -sf /usr/share/zoneinfo/MST7MDT /etc/localtime
+
# ##i##ln -s netif.tmpl netif.mybond
 +
# ##i##rc-update add netif.mybond default
 
</console>
 
</console>
  
The above sets the timezone to Mountain Standard Time (with daylight savings). Type <tt>ls /usr/share/zoneinfo</tt> to see what timezones are available. There are also sub-directories containing timezones described by location.
+
Now we can configure "mybond" using its configuration file <tt>/etc/conf.d/netif.mybond</tt>, just as we would a regular interface, except that we specify <tt>slaves</tt>:
 
+
==== /etc/make.conf ====
+
 
+
{{fancynote|This file is the symlink to /etc/portage/make.conf, new default location, edit /etc/portage/make.conf.}}
+
 
+
MAKEOPTS can be used to define how many parallel compilations should occur when you compile a package, which can speed up compilation significantly. A rule of thumb is the number of CPUs (or CPU threads) in your system plus one. If for example you have a dual core processor without [[wikipedia:Hyper-threading|hyper-threading]], then you would set MAKEOPTS to 3:
+
  
 
<pre>
 
<pre>
MAKEOPTS="-j3"  
+
template="bond"
 +
ipaddr="10.0.1.200/24"
 +
gateway="10.0.1.1"
 +
nameservers="10.0.1.1 10.0.1.2"
 +
domain="funtoo.org"
 +
slaves="netif.eth0 netif.eth1"
 
</pre>
 
</pre>
  
If you are unsure about how many processors/threads you have then use /proc/cpuinfo to help you.
+
In a bonded configuration, it is common to set the MTU to the maximum possible value supported by hardware to maximize throughput. In order to do this, simply set the MTU option in <tt>/etc/conf.d/netif.mybond</tt> to the maximum value supported by your hardware. The network scripts will ensure that this MTU setting is applied to all slave interfaces:
<console>
+
(chroot) # ##i##grep "processor" /proc/cpuinfo | wc -l
+
16
+
</console>
+
 
+
Set MAKEOPTS to this number plus one:
+
  
 
<pre>
 
<pre>
MAKEOPTS="-j17"
+
mtu=9000
 
</pre>
 
</pre>
  
USE flags define what functionality is enabled when packages are built. It is not recommended to add a lot of them during installation; you should wait until you have a working, bootable system before changing your USE flags. A USE flag prefixed with a minus ("<tt>-</tt>") sign tells Portage not to use the flag when compiling.  A Funtoo guide to USE flags will be available in the future. For now, you can find out more information about USE flags in the [http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=2&chap=2 Gentoo Handbook].
+
=== Bridge Configuration ===
  
LINGUAS tells Portage which local language to compile the system and applications in (those who use LINGUAS variable like OpenOffice). It is not usually necessary to set this if you use English. If you want another language such as French (fr) or German (de), set LINGUAS appropriately:
+
When hosting virtual machines, it can be convenient to use a bridge setup. This example shows how you would create a bridge (br0) with a simple static ip setup, containing two slave devices (eth0, tap0).
  
<pre>
+
First, ensure that your kernel is configured to support bridging (the module name is <tt>bridge</tt>) :
LINGUAS="fr"
+
</pre>
+
  
==== /etc/conf.d/hwclock ====
 
If you dual-boot with Windows, you'll need to edit this file and change '''clock''' to '''local''', because Windows will set your hardware clock to local time every time you boot Windows. Otherwise you normally wouldn't need to edit this file.
 
 
<console>
 
<console>
(chroot) # ##i##nano -w /etc/conf.d/hwclock
+
$ ##i##grep CONFIG_BRIDGE /usr/src/linux/.config
 +
CONFIG_BRIDGE=m
 +
CONFIG_BRIDGE_IGMP_SNOOPING=y
 
</console>
 
</console>
  
==== Localization ====
+
Second, make sure you have the required software installed:
 
+
By default, Funtoo Linux is configured with Unicode (UTF-8) enabled, and for the US English locale and keyboard. If you would like to configure your system to use a non-English locale or keyboard, see [[Funtoo Linux Localization]].
+
 
+
==== Profiles ====
+
 
+
[[Funtoo 1.0 Profile|Funtoo profiles]] are used to define defaults for Portage specific to your needs. There are 4 basic profile types: arch, build, [[Flavors and Mix-ins|flavor, and mix-ins]]:
+
 
+
;arch: typically <tt>x86-32bit</tt> or <tt>x86-64bit</tt>, this defines the processor type and support of your system. This is defined when your stage was built and should not be changed.
+
;build: defines whether your system is a <tt>current</tt>, <tt>stable</tt> or <tt>experimental</tt> build. <tt>current</tt> systems will have newer packages unmasked than <tt>stable</tt> systems.
+
;flavor: defines the general type of system, such as <tt>server</tt> or <tt>desktop</tt>, and will set default USE flags appropriate for your needs.
+
;mix-ins: define various optional settings that you may be interested in enabling.
+
 
+
One arch, build and flavor must be set for each Funtoo Linux system, while mix-ins are optional and you can enable more than one if desired.
+
 
+
Remember that profiles can often be inherited. For example, the <tt>desktop</tt> flavor inherits the <tt>workstation</tt> flavor settings, which in turn inherits the <tt>X</tt> and <tt>audio</tt> mix-ins. You can view this by using eselect:
+
  
 
<console>
 
<console>
(chroot) # ##i##eselect profile show
+
# ##i##emerge -av bridge-utils usermode-utilities
Currently set profiles:
+
    arch: gentoo:funtoo/1.0/linux-gnu/arch/x86-64bit
+
  build: gentoo:funtoo/1.0/linux-gnu/build/current
+
  flavor: gentoo:funtoo/1.0/linux-gnu/flavor/desktop
+
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/kde
+
 
+
Automatically enabled profiles:
+
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/print
+
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/X
+
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/audio
+
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/dvd
+
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/media
+
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/console-extras
+
 
+
 
+
 
</console>
 
</console>
  
To view installed profiles:
+
Then, create the necessary symlinks for the interfaces and add them to your default runlevel :
<console>
+
(chroot) # ##i##eselect profile list
+
</console>
+
  
To change the profile flavor:
 
 
<console>
 
<console>
(chroot) # ##i##eselect profile set-flavor 7
+
# ##i##cd /etc/init.d/
 +
# ##i##ln -s netif.tmpl netif.eth0
 +
# ##i##ln -s netif.tmpl netif.br0
 +
# ##i##ln -s netif.tmpl netif.tap0
 +
# ##i##rc-update add netif.br0 default
 +
# ##i##rc-update add netif.tap0 default
 
</console>
 
</console>
  
To add a mix-in:
+
Then, configure the slave interface <tt>/etc/conf.d/netif.eth0</tt> :
  
<console>
+
<pre>
(chroot) # ##i##eselect profile add 10
+
template="interface-noip"
</console>
+
</pre>
  
=== Configuring and installing the Linux kernel ===
+
Then, configure the slave interface <tt>/etc/conf.d/netif.tap0</tt> - note you only require group OR user, not both :
  
{{fancywarning|1=
+
<pre>
Please note that Linux kernel 3.13.* has some serious incompatibility with various graphics drivers. If you like to use <tt>gentoo-sources</tt> or <tt>vanilla-sources</tt>, please use a 3.12.* kernel. This is of particular importance if you plan to run GNOME, and want to use NVIDIA (commercial or nouveau) or ATI (ati-drivers) graphics drivers.}}
+
template="tap"
 +
group="kvm"
 +
user="kvm"
 +
mac_addr="10:20:30:40:50:66"
 +
</pre>
  
Now it's time to build and install a Linux kernel, which is the heart of any Funtoo Linux system. In the past, the process of creating a kernel that actually booted your system could be time-consuming and require a great deal of trial and error. Fortunately, Funtoo Linux offers an option to automatically build a kernel for you that will boot nearly all systems.
+
... and the bridge interface <tt>/etc/conf.d/netif.br0</tt> :
  
If you are unfamiliar with how to manually configure your own kernel, or you simply want to get your system up and running quickly, you can emerge <tt>debian-sources</tt> with the <tt>binary</tt> USE flag set, which will automatically build the kernel and an initrd that will boot nearly all Funtoo Linux systems. This kernel is based on a linux-3.2 LTS official debian kernel package and is an easy way to get your system up and running relatively quickly.
+
<pre>
 +
template="bridge"
 +
ipaddr="10.0.1.200/24"
 +
gateway="10.0.1.1"
 +
nameservers="10.0.1.1 10.0.1.2"
 +
domain="funtoo.org"
 +
slaves="netif.eth0 netif.tap0"
 +
stp="on"
 +
forwarding=1
 +
</pre>
  
Click [http://wiki.debian.org/DebianKernel here] for a list of all architectures the Debian kernel supports.
+
If you are using dhcpcd, you should ensure that it does not attempt to configure <tt>eth0</tt> or <tt>br0</tt> by adding the following to <tt>/etc/dhcpcd.conf</tt> :
 
+
{{fancyimportant|<tt>debian-sources</tt> with <tt>binary</tt> USE flag requires at least 12GB in /var/tmp}}
+
 
+
<console>
+
(chroot) # ##i##echo "sys-kernel/debian-sources binary" >> /etc/portage/package.use
+
(chroot) # ##i##emerge debian-sources</console>
+
 
+
All done!
+
 
+
{{fancynote|NVIDIA card users: the <tt>binary</tt> USE flag installs the Nouveau drivers which cannot be loaded at the same time as the proprietary drivers, and cannot be unloaded at runtime because of KMS. You need to blacklist it under <tt>/etc/modprobe.d/</tt>.}}
+
{{fancynote|For an overview of other kernel options for Funtoo Linux, see [[Funtoo Linux Kernels]]. There maybe modules that the Debian kernel doesn't include, a situation where [http://www.funtoo.org/wiki/Funtoo_Linux_Kernels#Using_Debian-Sources_with_Genkernel genkernel] would be useful. Also be sure to see [[:Category:Hardware Compatibility|hardware compatibility]] information. We have compiled a very good reference for [[Dell PowerEdge 11G Servers]] that includes kernel compatibility information as well..}}
+
 
+
 
+
The next step is to configure your boot loader so that your new kernel loads when the system boots.
+
 
+
=== Installing a Bootloader ===
+
 
+
==== Installing Grub ====
+
 
+
The boot loader is responsible for loading the kernel from disk when your computer boots. For new installations, GRUB 2 and Funtoo's boot-update tool should be used as a boot loader. GRUB supports both GPT/GUID and legacy MBR partitioning schemes.
+
 
+
To use this recommended boot method, first emerge <tt>boot-update</tt>. This will also cause <tt>grub-2</tt> to be merged, since it is a dependency of <tt>boot-update</tt>.
+
 
+
<console>
+
(chroot) # ##i##emerge boot-update
+
</console>
+
 
+
Then, edit <tt>/etc/boot.conf</tt> and specify "<tt>Funtoo Linux genkernel</tt>" as the <tt>default</tt> setting at the top of the file, replacing <tt>"Funtoo Linux"</tt>.
+
 
+
<tt>/etc/boot.conf</tt> should now look like this:
+
  
 
<pre>
 
<pre>
boot {
+
# don't attempt to pull an ip address for br0 or its slave device
        generate grub
+
denyinterfaces eth0 br0
        default "Funtoo Linux genkernel"
+
        timeout 3
+
}
+
 
+
"Funtoo Linux" {
+
        kernel bzImage[-v]
+
        # params += nomodeset
+
}
+
 
+
"Funtoo Linux genkernel" {
+
        kernel kernel[-v]
+
        initrd initramfs[-v]
+
        params += real_root=auto
+
        # params += nomodeset
+
}
+
 
</pre>
 
</pre>
 
Please read <tt>man boot.conf</tt> for further details.
 
  
===== Running grub-install and boot-update =====
+
=== More Complex Network Configuration ===
  
Finally, we will need to actually install the GRUB boot loader to your disk, and also run <tt>boot-update</tt> which will generate your boot loader configuration file:
+
If the standard templates don't work for your needs, simply create a new template -- I recommend starting from the <tt>interface</tt> template for most things:
  
<console>
+
<console># ##i##cd /etc/netif.d
(chroot) # ##i##grub-install --no-floppy /dev/sda
+
# ##i##cp interface custom</console>
(chroot) # ##i##boot-update
+
You can now call whatever commands you need to <tt>/etc/netif.d/custom</tt>. The following shell functions can be defined in a network script:
</console>
+
  
You only need to run <tt>grub-install</tt> when you first install Funtoo Linux, but you need to re-run <tt>boot-update</tt> every time you modify your <tt>/etc/boot.conf</tt> file, so your changes are applied on next boot.
+
==== netif_create ====
  
OK - your system should be ready to boot! Well, there are a few more loose ends...
+
In <tt>netif_create</tt>, you should call any commands to create the interface if it does not yet exist.
  
==== Installing Syslinux/Extlinux ====
+
==== netif_depend ====
  
An alternate boot loader called extlinux can be used instead of GRUB if you desire. See the [[Extlinux|extlinux Guide]] for information on how to do this.
+
In <tt>netif_depend</tt>, you can define dependencies, using the functions <tt>need</tt> and <tt>use</tt>.
  
=== Configuring your network ===
+
==== netif_pre_up ====
  
It's important to ensure that you will be able to connect to your local-area network after you reboot into Funtoo Linux. There are three approaches you can use for configuring your network: NetworkManager, dhcpcd, and the [[Funtoo Linux Networking]] scripts. Here's how to choose which one to use based on the type of network you want to set up.
+
In <tt>netif_pre_up</tt>, you can define network configuration actions to perform prior to bringing the interface up. You can also ensure certain variables are specified by calling <tt>require var1 [var2...]</tt> here.
  
==== Wi-Fi ====
+
==== netif_post_up====
  
For laptop/mobile systems where you will be using Wi-Fi and connecting to various networks, NetworkManager is strongly recommended. The Funtoo version of NetworkManager is fully functional even from the command-line, so you can use it even without X or without the Network Manager applet. Here are the steps involved in setting up NetworkManager:
+
In <tt>netif_post_up</tt>, you can define network configuration actions to perform after bringing the interface up.
  
<console>
+
==== netif_pre_down ====
# ##i##emerge linux-firmware
+
# ##i##emerge networkmanager
+
# ##i##rc-update add NetworkManager default
+
</console>
+
  
Above, we installed linux-firmware which contains a complete collection of available firmware for many hardware devices including Wi-Fi adapters, plus NetworkManager to manage our network connection. Then we added NetworkManager to the <tt>default</tt> runlevel so it will start when Funtoo Linux boots.
+
In <tt>netif_pre_down</tt>, you can define network configuration actions to perform prior to bringing the interface down.
  
After you reboot into Funtoo Linux, you will be able to add a Wi-Fi connection this way:
+
==== netif_post_down ====
  
<console>
+
In <tt>netif_post_down</tt>, you can define network configuration actions to perform after bringing the interface down.
# ##i##addwifi -S wpa -K 'wifipassword' mywifinetwork
+
</console>
+
  
The <tt>addwifi</tt> command is used to configure and connect to a WPA/WPA2 Wi-Fi network named <tt>mywifinetwork</tt> with the password <tt>wifipassword</tt>. This network configuration entry is stored in <tt>/etc/NetworkManager/system-connections</tt> so that it will be remembered in the future. You should only need to enter this command once for each Wi-Fi network you connect to.
+
==== netif_destroy ====
  
==== Desktop (Wired Ethernet) ====
+
In <tt>netif_destroy</tt>, you can call any commands necessary to destroy/delete the interface if it is dynamic in nature (tun/tap, etc.)
  
For a home desktop or workstation with wired Ethernet that will use DHCP, the simplest and most effective option to enable network connectivity is to simply add <tt>dhcpcd</tt> to the default runlevel:
+
==== How It Works ====
  
<console>
+
You do not specify a function for actually bringing up the interface, because the template-based system does this for you. The template-based system also performs all normal actions required to bring an interface down, so you only need to specify atypical actions that must be performed - such as removing child interfaces or destroying a bridge using <tt>brctl</tt>.
# ##i##rc-update add dhcpcd default
+
</console>
+
  
When you reboot, <tt>dhcpcd</tt> will run in the background and manage all network interfaces and use DHCP to acquire network addresses from a DHCP server.
+
When you create your own network configuration template, the following capabilities are available for use automatically, as long as the appropriate variables are set in the <tt>/etc/conf.d/netif.&lt;ifname&gt;</tt> file, without requiring any explicit steps on your part:
  
==== Server (Static IP) ====
+
* DNS configuration using <tt>domain</tt> and <tt>nameservers</tt> config settings. OpenResolv is used automatically.
 +
* VLAN configuration using auto-naming (<tt>netif.ethX.Y</tt>) or via custom naming with <tt>trunk</tt> and <tt>vlan</tt> config settings.
 +
* Default IPv4 gateway and route configuration using the <tt>gateway</tt> and <tt>route</tt> settings.
 +
* Default IPv6 gateway and route configuration using the <tt>gateway6</tt> and <tt>route6</tt> settings.
 +
* MTU configuration using the <tt>mtu</tt> setting.
 +
* Auto-depend (and auto-MTU configuration) of slave interfaces specified using <tt>slaves</tt> setting.
 +
* Renaming of existing network interface (specify MAC address using <tt>macaddr</tt> setting).
  
For servers, the [[Funtoo Linux Networking]] scripts are recommended. They are optimized for static configurations and things like virtual ethernet bridging for virtualization setups. See [[Funtoo Linux Networking]] for information on how to use Funtoo Linux's template-based network configuration system.
+
To take advantage of this functionality, simply enable the appropriate variables.
  
=== Finishing Steps ===
+
All other necessary network configuration and dependency behavior should be defined using the <tt>netif_</tt>-prefix functions described above.
  
==== Set your root password ====
+
== Wireless Configuration ==
It's imperative that you set your root password before rebooting so that you can log in.
+
<console>
+
(chroot) # ##i##passwd
+
</console>
+
 
+
===Restart your system ===
+
 
+
Now is the time to leave chroot, to unmount Funtoo Linux partitions and files and to restart your computer. When you restart, the GRUB boot loader will start, load the Linux kernel and initramfs, and your system will begin booting.
+
 
+
Leave the chroot, change directory to /, unmount your Funtoo partitions, and reboot.
+
<console>
+
(chroot) # ##i##exit
+
# ##i##cd /
+
# ##i##umount -l /mnt/funtoo/boot /mnt/funtoo/dev /mnt/funtoo/proc /mnt/funtoo/sys /mnt/funtoo
+
# ##i##reboot
+
</console>
+
  
You should now see your system reboot, the GRUB boot loader appear for a few seconds, and then see the Linux kernel and initramfs loading. After this, you should see Funtoo Linux itself start to boot, and you should be greeted with a <tt>login:</tt> prompt. Funtoo Linux has been successfully installed!
+
The recommended approach for setting up Wi-Fi under Funtoo Linux is to use NetworkManager. Steps are provided in the [[Funtoo Linux Installation#Wi-Fi|Wi-Fi section of the Funtoo Linux Installation Guide]].
  
===Next Steps===
+
== Other Network Configurations ==
  
If you are brand new to Funtoo Linux and Gentoo Linux, please check out [[Funtoo Linux First Steps]], which will help get you acquainted with your new system.
+
If you have a network configuration template that might be useful to others, please post it to the [http://groups.google.com/group/funtoo-dev funtoo-dev mailing list] so we can review it and possibly incorporate it into Funtoo.
  
We also have a number of pages dedicated to setting up your system, which you can find below. If you are interested in adding a page to this list, add it to the "First Steps" MediaWiki category.
+
== License ==
  
{{#ask: [[Category:First Steps]] | format=category }}
+
Funtoo Linux networking scripts are released under the following license:
  
If your system did not boot correctly, see [[Installation Troubleshooting]] for steps you can take to resolve the problem.
+
{{BSD2 Funtoo|src=http://github.com/funtoo/corenetwork}}
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
 +
[[Category:Projects]]
 +
[[Category:Networking]]
 
[[Category:Install]]
 
[[Category:Install]]
 +
[[Category:Funtoo features]]
 
[[Category:Official Documentation]]
 
[[Category:Official Documentation]]

Revision as of 00:19, 13 March 2014

This document explains how to configure your network settings by explaining the network configuration functionality available in Funtoo Linux. Also covered is dhcpcd 5.x, Wi-Fi (IEEE 802.11) configuration, and the OpenResolv framework.

Contents

Introduction

Funtoo Linux has its own core network configuration system that differs somewhat from upstream network configuration systems used in Gentoo Linux and OpenRC.

In this document, I will explain the unique additions and changes to the Funtoo network configuration and show you how to use this system to configure your network.

I'll also explain how to use dhcpcd 5.x for managing network interfaces on DHCP-based networks, and will also cover OpenRC stacked runlevel configuration, Wi-Fi (IEEE 802.11) configuration, and the OpenResolv framework, which is enabled in Funtoo Linux by default.

A Gentle Introduction to Funtoo Network Configuration

Before I get into the technical details of configuring your network, it's important to understand that Funtoo Linux has a number of different options available to you for network configuration, with more likely to be added in the future. Each approach is different and has its own strengths and weaknesses, and this is, in my opinion, a good thing.

The Easy (Dynamic) Way

When configuring your network, one option is to skip traditional network configuration and simply rely on DHCP. This is by far the simplest method of configuring your network. If you are on a wired network, no other steps are typically required beyond enabling a DHCP client, and Funtoo Linux includes dhcpcd 5.x by default.

Network Manager, Wicd

If you are going to use a third party package such as Network Manager or Wicd to manage your network then you do not need to configure DHCP at all. These packages configure DHCP for you. Simply emerge the package you want to use and start using it.

DHCP-Only Systems

If you are not planning to use a third-party package to manage your network interfaces, it is still extremely easy to set up DHCP networking, especially if you always use DHCP to connect to networks, which is common for desktops or laptops. In this scenario, we can simply enable dhcpcd to run at system startup. It will run in the background and automatically look for DHCP servers on all your network interfaces, and will attempt to lease an IP address from any DHCP servers found.

If this sounds like what you want to do, then add dhcpcd to your default runlevel as follows:

# rc-update add dhcpcd default

To enable DHCP immediately, you would follow the previous command with an rc command, which would start the dhcpcd client you just added:

# rc

If you're on a wired network and have the necessary drivers in your kernel, then this should get you going. For wireless networks, more steps are required to utilize your wireless hardware to associate with an access point, which will be covered later in this document.

Tweaking Dhcpcd

For now, it's important to note that dhcpcd 5.x will manage all available network interfaces by default. If you want to run a DHCP client on all but one interface, or some other subset of interfaces, you can add the appropriate denyinterfaces or allowinterfaces glob pattern to /etc/dhcpcd.conf:

# manage all interfaces but eth0 with dhcpcd
denyinterfaces eth0

This can also be accomplished by modifying /etc/init.d/dhcpcd directly and adding -Z ifglob or -z ifglob (the equivalent command-line parameters) to command_args.

Using Funtoo Scripts for DHCP

You can also use the Funtoo Linux networking scripts to start a DHCP client just on a specific interface. This approach is best if you are planning to also do some advanced bridging, bonding or VLAN configuration on your machine along with DHCP, since you will be using the Funtoo Linux networking scripts for that too.

To use this variant approach, don't enable /etc/init.d/dhcpcd directly. Instead, use the Funtoo Linux dhcpcd template which will start dhcpcd on only one interface. Below, you will see the steps to do this. This is very similar to how we set up advanced network interfaces, which will be covered later in this documentation:

# cd /etc/init.d
# ln -s netif.tmpl netif.eth0
# rc-update add netif.eth0 default
# echo template=dhcpcd > /etc/conf.d/netif.eth0
# rc

The last command, rc, causes netif.eth0 to be started.

Server Network Configuration

For servers and advanced networking scenarios, Funtoo Linux offers its own modular, template-based network configuration system. This system offers a lot of flexibility for configuring network interfaces, essentially serving as a "network interface construction kit." This system can be used by itself, or even combined with dhcpcd, as shown in the previous section.

Here are the key components of the template-based network configuration system:

/etc/init.d/netif.lo
An init script that configures the localhost interface. This script is always enabled and is part of the boot process.
/etc/netif.d
This is a directory that contains various network configuration templates. Each of these templates is focused on configuring a particular type of network interface, such as a general static IP-based interface, a bridge interface, a bond interface, etc.
/etc/init.d/netif.tmpl
This is the master init script for the template-based network configuration system. New interfaces are added to your system by creating symbolic links to this file in /etc/init.d.

So, if you wanted to use this system to configure eth0 with a static IP address, you would create a netif.eth0 symlink to netif.tmpl as follows:

# cd /etc/init.d
# ln -s netif.tmpl netif.eth0

Then, you would create an /etc/conf.d/netif.eth0 configuration file that would specify which template to use from the /etc/netif.d directory:

template="interface"
ipaddr="10.0.1.200/24"
gateway="10.0.1.1"
nameservers="10.0.1.1 10.0.1.2"
domain="funtoo.org"

To complete our static IP network configuration we would need to:

# rc-update add netif.eth0 default

When configuring your own static network interface, one of ipaddr or ipaddrs is required and should specify the IP address(es) to configure for this interface, in "a.b.c.d/netmask" format. Optional parameters include gateway, which defines a default gateway for your entire network, and if set should specify the gateway's IP address. In addition, domain and nameservers (space-separated if more than one) can be used to specify DNS information for this interface.

Configuration Variables

Interface Variables

The ipaddr and ipaddrs variables are supported by the interface and bridge templates, and are used to specify a single or multiple IPv4 or IPv6 address(es) for the interface. IP addresses should be specified in 'IP/netmask' format, such as 10.0.0.1/24. Multiple IP addresses can be specified delimited by whitespace:

ipaddrs="10.0.0.1/24 10.0.0.2/24"
Broadcast Address

By default, a broadcast address will be calculated based on the IP address and network mask. If you need to manually specify a broadcast address, use the following format for your IP address:

ipaddrs="10.0.0.1/24;broadcast=10.0.1.255 10.0.0.2/24"
Not Specifying An Address

Note that in some cases, you may choose to not specify ipaddr or ipaddrs for a bridge template. That is allowed. If you don't want to specify an IP address for a regular interface, you can choose to use the interface template without an IP address specified in the config, or use the interface-noip template instead, for the sake of clarity.

Viewing All Configured IP Addresses

Also note that if you specify multiple IPv4 addresses, ifconfig will only show the first IP address. To view all IP addresses associated with the interface, use the ip addr show command.

General Variables

The following variables are enabled by default for all network scripts, and if specified will trigger a corresponding configuration action:

nameservers
Set DNS nameservers using OpenResolv. Specify multiple IPv4 or IPv6 nameservers like this: "1.2.3.4 1.2.3.5 1.2.3.6". Please note that OpenResolv treats 127.0.0.1 specially, and it indicates that you are running a local name resolver like dnsmasq or bind. OpenResolv will ignore all other name servers specified alongside 127.0.0.1. See man resolvconf and man resolvconf.conf for additional setup information.
search
Set DNS search information using OpenResolv.
domain
Set DNS domain using OpenResolv.
gateway
Define a default IPv4 gateway on this interface.
gateway6
Define a default IPv6 gateway on this interface.
route
Specify a semi-colon delimited list of IPv4 routes to apply when this interface is brought up. Will be appended to ip -4 route add.
route6
Specify a semi-colon delimited list of IPv6 routes to apply when this interface is brought up. Will be appended to ip -6 route add.
mtu
Set Maximum Transmit Unit for the interface


VLAN Variables

VLAN support is enabled by default for all network configuration scripts. If a network script has a name in the format netif.ethX.Y, then it is assumed to be a VLAN interface referencing trunk ethX and VLAN ID Y. If you desire a custom name for your VLAN interface, you can name your interface whatever you'd like and specify the following variables in your interface config:

trunk
VLAN trunk interface, e.g. "eth0"
vlan
VLAN id, e.g. "32"

Bridge / Tap Variables

The following variables for configuring a functional bridge interface with optional tap interfaces:

slaves
Set slave interfaces of this interface (for bridges, etc.) All slaves will automatically be depended upon, and will also automatically have their mtu set to that of the current interface, if an mtu is specified for the current interface. This setting is required for the bond template and optional for the bridge template.
stp
Enables Spanning Tree Protocol on a bridge interface like this "stp=on"
forwarding
Enables forwarding on a bridge interface by calling sysctl; as this interface does not exist when sysctl is called by init, we do it here. If this is disabled, your bridge will not forward traffic back out onto the network. useage: "forwarding=1"
mac_addr
Sets a MAC address on a tap interface. This is usefull for avoiding layer2 address collisions when using large numbers of TUN interfaces (KVM, openVPN, ect)

OpenResolv and resolv.conf

OpenResolv will be used to set DNS information provided by the nameservers, domain and search variables when an interface is brought up. The OpenResolv framework will add entries to /etc/resolv.conf, and will also handle removing these entries when the interface is brought down. This way, /etc/resolv.conf should always contain current information and should not need to be manually edited by the system administrator. dhcpcd will use OpenResolv for updating system DNS information as well.

Network-Dependent Services

One important difference between Gentoo Linux and Funtoo Linux is that, in Funtoo Linux, network-dependent services only strictly depend on netif.lo. This means that if another network service requires an interface to be up, such as samba requiring eth0, then the system administrator must specify this relationship by adding the following line to /etc/conf.d/samba:

rc_need="netif.eth0"

This will have the effect of ensuring that netif.eth0 is started prior to samba and that samba is stopped prior to stopping netif.eth0.

Many network services, especially those that listen on all network intefaces, don't need an rc_need line in order to function properly. Avoiding the use of rc_need when required will optimize boot times and allow more network services to remain available when network interfaces are brought up and down by the system administrator.

Multiple Network Configurations

For information on how to have multiple, independent network configurations, please see Stacked Runlevels.

Alternate Configs

If you need to run the same service with different configuration parameters depending upon runlevel, then you'll be happy to know that you can specify runlevel-specific conf.d files by appending a . <runlevel> suffix. In this particular example, we could imagine a situation where we had two child runlevels named home and work:

/etc/conf.d/netif.eth0.home
/etc/conf.d/netif.eth0.work
Note that this feature works for all init scripts, not just network configuration scripts.

Interface Renaming

Funtoo network scripts now support interface renaming, so you can create an interface called lan if you would like. To do this, simply specify the MAC address of the interface you would like to rename using the macaddr variable:

macaddr="00:15:17:19:b6:a3"
If this MAC address is part of the netif.lan configuration file, then when this interface starts, whatever interface currently has the MAC address of 00:15:17:19:b6:a3 (i.e. eth5) will be renamed to lan prior to the interface being brought up, and will show up in ifconfig and ip commands as being an interface named lan.

Basic VLAN Configuration

The standard interface template supports VLANs. To use VLAN support, first ensure that your kernel was compiled with VLAN support (the module name is 8021q) :

# grep CONFIG_VLAN /usr/src/linux/.config
CONFIG_VLAN_8021Q=m
CONFIG_VLAN_8021Q_GVRP=y

Then, configure the trunk interface using the interface-noip template. Assuming eth1 is trunked, you would create the file /etc/conf.d/netif.eth1 with the following contents:

template="interface-noip"

Then, create a network interface symlink for the trunk and add it to your default runlevel:

# cd /etc/init.d
# ln -s netif.tmpl netif.eth1
# rc-update add netif.eth1 default

Now, assuming you wanted to configure a VLAN of 32, you would create a config file named /etc/conf.d/netif.eth1.32 that looks something like this:

template="interface"
ipaddr="1.2.3.4/24"
gateway="1.2.3.1"# etc...

Then, create a VLAN network interface symlink and add it to your default runlevel:

# cd /etc/init.d
# ln -s netif.tmpl netif.eth1.32
# rc-update add netif.eth1.32 default

The Funtoo network configuration scripts will automatically recognize the filename netif.eth1.32 as being VLAN 32 of trunk interface netif.eth1.

When the VLAN interface is brought up, it will be named eth1.32.

Custom VLAN Names

However, sometimes you may want to turn off automatic file-based VLAN naming and give your VLAN interface a custom name, such as mgmt. To do this, you would set up the trunk interface in the exact same way as described above, but instead of creating a netif.eth1.32 interface, you would create a netif.mgmt interface, and specify vlan and trunk in the /etc/conf.d/netif.mgmt config file, as follows:

template="interface"
vlan="32"
trunk="eth1"
ipaddr="1.2.3.4/24"
gateway="1.2.3.1"
# etc...

When you specify trunk and vlan in the interface config file, filename-based auto-detecting of VLAN ID and trunk is disabled. Both trunk and vlan must be specified -- you can't specify just one.

Then you would simply create a VLAN network interface symlink for netif.mgmt:

# cd /etc/init.d
# ln -s netif.tmpl netif.mgmt
# rc-update add netif.mgmt default

When the VLAN interface is brought up, it will be named mgmt.

Bonding Configuration

Bonding allows you to aggregate multiple network interfaces into a single logical network interface, allowing for benefits in throughput as well as resiliency in the case that an individual interface may go down. This example shows how you would create a bonding interface (mybond) with a simple static ip setup, containing two slave devices (eth0 and eth1).

First, ensure that your kernel is configured to support bonding (the module name is bonding) :

$ grep CONFIG_BONDING /usr/src/linux/.config
CONFIG_BONDING=m

You'l want to ensure that CONFIG_BONDING is set to "m" or "y". You can find this kernel configuration option tucked under "Device Drivers" -> "Network Device Support" -> "Bonding driver support". Be sure that ifenslave is emerged:

emerge ifenslave

Once bonding is enabled in the kernel, you will need to choose at least two devices to bond together. These will be set up as "slave" interfaces with no IP address.

# cd /etc/init.d/
# ln -s netif.tmpl netif.eth0
# ln -s netif.tmpl netif.eth1

Then, configure the slave interfaces by creating /etc/conf.d/netif.eth0 and /etc/conf.d/netif.eth1 with the following contents:

template="interface-noip"

Now, we will create the bond interface and make netif.eth0 and netif.eth1 slaves of this interface. Note that our bond interface can have any name. To demonstrate this, we will give it the name of "mybond" below:

# ln -s netif.tmpl netif.mybond
# rc-update add netif.mybond default

Now we can configure "mybond" using its configuration file /etc/conf.d/netif.mybond, just as we would a regular interface, except that we specify slaves:

template="bond"
ipaddr="10.0.1.200/24"
gateway="10.0.1.1"
nameservers="10.0.1.1 10.0.1.2"
domain="funtoo.org"
slaves="netif.eth0 netif.eth1"

In a bonded configuration, it is common to set the MTU to the maximum possible value supported by hardware to maximize throughput. In order to do this, simply set the MTU option in /etc/conf.d/netif.mybond to the maximum value supported by your hardware. The network scripts will ensure that this MTU setting is applied to all slave interfaces:

mtu=9000

Bridge Configuration

When hosting virtual machines, it can be convenient to use a bridge setup. This example shows how you would create a bridge (br0) with a simple static ip setup, containing two slave devices (eth0, tap0).

First, ensure that your kernel is configured to support bridging (the module name is bridge) :

$ grep CONFIG_BRIDGE /usr/src/linux/.config
CONFIG_BRIDGE=m
CONFIG_BRIDGE_IGMP_SNOOPING=y

Second, make sure you have the required software installed:

# emerge -av bridge-utils usermode-utilities

Then, create the necessary symlinks for the interfaces and add them to your default runlevel :

# cd /etc/init.d/
# ln -s netif.tmpl netif.eth0
# ln -s netif.tmpl netif.br0
# ln -s netif.tmpl netif.tap0
# rc-update add netif.br0 default
# rc-update add netif.tap0 default

Then, configure the slave interface /etc/conf.d/netif.eth0 :

template="interface-noip"

Then, configure the slave interface /etc/conf.d/netif.tap0 - note you only require group OR user, not both :

template="tap"
group="kvm" 
user="kvm"
mac_addr="10:20:30:40:50:66"

... and the bridge interface /etc/conf.d/netif.br0 :

template="bridge"
ipaddr="10.0.1.200/24"
gateway="10.0.1.1"
nameservers="10.0.1.1 10.0.1.2"
domain="funtoo.org"
slaves="netif.eth0 netif.tap0"
stp="on"
forwarding=1

If you are using dhcpcd, you should ensure that it does not attempt to configure eth0 or br0 by adding the following to /etc/dhcpcd.conf :

# don't attempt to pull an ip address for br0 or its slave device
denyinterfaces eth0 br0

More Complex Network Configuration

If the standard templates don't work for your needs, simply create a new template -- I recommend starting from the interface template for most things:

# cd /etc/netif.d
# cp interface custom

You can now call whatever commands you need to /etc/netif.d/custom. The following shell functions can be defined in a network script:

netif_create

In netif_create, you should call any commands to create the interface if it does not yet exist.

netif_depend

In netif_depend, you can define dependencies, using the functions need and use.

netif_pre_up

In netif_pre_up, you can define network configuration actions to perform prior to bringing the interface up. You can also ensure certain variables are specified by calling require var1 [var2...] here.

netif_post_up

In netif_post_up, you can define network configuration actions to perform after bringing the interface up.

netif_pre_down

In netif_pre_down, you can define network configuration actions to perform prior to bringing the interface down.

netif_post_down

In netif_post_down, you can define network configuration actions to perform after bringing the interface down.

netif_destroy

In netif_destroy, you can call any commands necessary to destroy/delete the interface if it is dynamic in nature (tun/tap, etc.)

How It Works

You do not specify a function for actually bringing up the interface, because the template-based system does this for you. The template-based system also performs all normal actions required to bring an interface down, so you only need to specify atypical actions that must be performed - such as removing child interfaces or destroying a bridge using brctl.

When you create your own network configuration template, the following capabilities are available for use automatically, as long as the appropriate variables are set in the /etc/conf.d/netif.<ifname> file, without requiring any explicit steps on your part:

  • DNS configuration using domain and nameservers config settings. OpenResolv is used automatically.
  • VLAN configuration using auto-naming (netif.ethX.Y) or via custom naming with trunk and vlan config settings.
  • Default IPv4 gateway and route configuration using the gateway and route settings.
  • Default IPv6 gateway and route configuration using the gateway6 and route6 settings.
  • MTU configuration using the mtu setting.
  • Auto-depend (and auto-MTU configuration) of slave interfaces specified using slaves setting.
  • Renaming of existing network interface (specify MAC address using macaddr setting).

To take advantage of this functionality, simply enable the appropriate variables.

All other necessary network configuration and dependency behavior should be defined using the netif_-prefix functions described above.

Wireless Configuration

The recommended approach for setting up Wi-Fi under Funtoo Linux is to use NetworkManager. Steps are provided in the Wi-Fi section of the Funtoo Linux Installation Guide.

Other Network Configurations

If you have a network configuration template that might be useful to others, please post it to the funtoo-dev mailing list so we can review it and possibly incorporate it into Funtoo.

License

Funtoo Linux networking scripts are released under the following license:


BSD 2-Clause Funtoo License

This work is free software. Source code is available.

Copyright 2009-2011 Funtoo Technologies. You can redistribute and/or modify it under the terms of the 2-clause BSD license. Alternatively you may (at your option) use any other license that has been publicly approved for use with this program by Funtoo Technologies (or its successors, if any.)