Difference between revisions of "Install/Network"

From Funtoo
Jump to navigation Jump to search
m (Corrected English and removed "especially for GUI environments" as this doesn't make much sense, wpa_supplicant has a perfectly good GUI, if anything NM is better as a cli tool.)
 
(34 intermediate revisions by 7 users not shown)
Line 1: Line 1:
<noinclude>
<translate>
{{InstallPart|Network configuration}}
<includeonly>
</noinclude>
== Network == <!--T:1-->
=== Configuring your network ===
</includeonly><noinclude><languages/>
= Install Guide: Network =


<!--T:2-->
{{InstallNavigation|num=15|prev=Bootloader|next=Finishing}}</noinclude>
<!--T:35-->
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.
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.


==== Wi-Fi ====
==== Wi-Fi ==== <!--T:18-->  
===== Using NetworkManager =====
For laptop/mobile systems where you will be using Wi-Fi and connecting to various networks NetworkManager is strongly recommended.  Here are the steps involved in setting up NetworkManager:
 
<console>
(chroot) # ##i##emerge linux-firmware
(chroot) # ##i##emerge networkmanager
(chroot) # ##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 <code>default</code> runlevel so it will start when Funtoo Linux boots.
 
After you reboot into Funtoo Linux, you will be able to add a Wi-Fi connection this way:
 
{{Note|The following command will not work as long as you are in chroot environment. The reason for this is that addwifi will need dbus and rfkill to be set up. So don't forget to reboot!}}
 
<console>
# ##i##addwifi -S wpa -K 'wifipassword' mywifinetwork
</console>
 
The <code>addwifi</code> command is used to configure and connect to a WPA/WPA2 Wi-Fi network named <code>mywifinetwork</code> with the password <code>wifipassword</code>. This network configuration entry is stored in <code>/etc/NetworkManager/system-connections</code> 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.
 
===== Using wpa_supplicant =====
If a wireless connection working even in a command-line environment is needed, a tool as wpa_supplicant is adviced.
 
Before installing wpa_supplicant, we should first enable the wirelees flag (called <code>wps</code>)for the installation of the package:
 
{{Note|In this scenario we are considering a raw command-line environment installation, if a GUI environment is considered it is adviced to enable even the <code>qt4</code> flag in order to be able to use wpa_gui}}
 
<console>
(chroot) ###i## echo '=net-wireless/wpa_supplicant wps' >> /etc/portage/package.use
</console>
 
Now, we can emerge dhcpcd and wpa_supplicant, by doing:


<console>
<!--T:36-->
(chroot) ###i## emerge -a dhcpcd
{{Note|If using the ''{{c|gnome}}'' or other desktop install image, {{c|linux-firmware}} and NetworkManager are already installed and available. You can use {{c|nmtui}} to get Wi-Fi going if you need network connectivity prior to getting X and GNOME fully up and running. In addition, desktop stage3's have ZeroConf/Bonjour multicast DNS lookups enabled by default. Both these things will ''not'' be set up yet if you are using the basic ''{{c|stage3}}'' image.}}
(chroot) ###i## emerge linux-firmware
(chroot) ###i## emerge -a wpa_supplicant
</console>


Now we have to tell dhcpcd to use automatically wpa_supplicant, this can be done editing the file  <code>/etc/conf.d/net </code>.
<!--T:19-->
For laptop/mobile systems where you will be using Wi-Fi, roaming, and connecting to various networks, NetworkManager is strongly recommended. 
Since Wi-Fi cards require firmware to operate, it is also recommended that you emerge the linux-firmware ebuild if you have not done so already:


<pre>
<!--T:23-->
modules_wlan0="wpa_supplicant"
{{console|body=%chroot% ##i##emerge linux-firmware networkmanager
config_wlan0="dhcp"
%chroot% ##i##rc-update add NetworkManager default
</pre>
}}
The above command will ensure that NetworkManager starts after you boot into Funtoo Linux. Once you've completed these installation steps and have booted into Funtoo Linux, you can use the {{c|nmtui}} command (which has an easy-to-use console-based interface) to configure NetworkManager so that it will connect (and automatically reconnect, after reboot) to a Wi-Fi access point:
{{console|body=%chroot% ##i##nmtui}}
For more information about NetworkManager, see the [[Package:NetworkManager|NetworkManager package page]].


Now, edit the wpa_supplicant configuration file, located at  <code>/etc/wpa_supplicant/wpa_supplicant.conf </code>.
==== Desktop (Wired DHCP) ==== <!--T:24-->
The syntax is very easy  (The example below refers to a connection to a WPA/WPA2 encrypted connection):


<pre>
<!--T:26-->
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
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 {{c|dhcpcd}} to the default runlevel:
#ap_scan=0
#update_config=1
network={
        ssid="YourSSID"
        psk="your-secret-key"
        scan_ssid=1
        proto=RSN
        key_mgmt=WPA-PSK
        group=CCMP TKIP
        pairwise=CCMP TKIP
        priority=5
}
</pre>


Note that you will need to add <code>dhcpcd</code> to the default runlevel, and it will automatically manage the connection through wpa_supplicant. <code>wpa_supplicant</code> will connect to your access point, and <code>dhcpcd</code> will acquire an IP address via DHCP:
<!--T:27-->
{{console|body=
%chroot% ##i##rc-update add dhcpcd default}}
When you reboot, {{c|dhcpcd}} will run in the background and manage all network interfaces and use DHCP to acquire network addresses from a DHCP server.


<console>
<!--T:28-->
(chroot) # ##i##rc-update add dhcpcd default
If your upstream DHCP server is dnsmasq, it can be configured to assign addresses via mac address to make servers on DHCP feasible.
</console>


==== Desktop (Wired Ethernet) ====
==== Server (Static IP) ==== <!--T:29-->


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 <code>dhcpcd</code> to the default runlevel:
<!--T:30-->
For servers, the [[Funtoo Linux Networking]] scripts are the supported option for network configuration, and they [[Funtoo Linux Networking|have their own documentation]]. 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.


<console>
==== Hostname ==== <!--T:31-->
(chroot) # ##i##rc-update add dhcpcd default
By default Funtoo uses "localhost" as hostname. Although the system will work perfectly fine using this name, some ebuilds refuse to install when detecting localhost as hostname. It also may create confusion if several systems use the same hostname. Therefore, it is advised to change it to a more meaningful name. The hostname itself is arbitrary, meaning you can choose almost any combination of characters, as long as it makes sense to the system administrator. To change the hostname, edit
</console>


When you reboot, <code>dhcpcd</code> will run in the background and manage all network interfaces and use DHCP to acquire network addresses from a DHCP server.
<!--T:32-->
{{console|body=
%chroot% ##i##nano /etc/conf.d/hostname
}}


==== Server (Static IP) ====
<!--T:33-->
Look for the line starting with hostname and change the entry between the quotes. Save the file, on the next boot Funtoo will use the new hostname.


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.
<!--T:34-->
{{warning|Hostnames can be up to 63 characters long and may use the following characters: a-z, 0-9 and hyphens (-). However, the hyphen may not be the first or last character.}}
</translate>
<noinclude>{{InstallNavigation|num=15|prev=Bootloader|next=Finishing|align=right}}</noinclude>

Latest revision as of 22:59, October 6, 2022

Other languages:

Install Guide: Network

Install Guide, Chapter 15 < Prev Next >

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.

Wi-Fi

   Note

If using the gnome or other desktop install image, linux-firmware and NetworkManager are already installed and available. You can use nmtui to get Wi-Fi going if you need network connectivity prior to getting X and GNOME fully up and running. In addition, desktop stage3's have ZeroConf/Bonjour multicast DNS lookups enabled by default. Both these things will not be set up yet if you are using the basic stage3 image.

For laptop/mobile systems where you will be using Wi-Fi, roaming, and connecting to various networks, NetworkManager is strongly recommended. Since Wi-Fi cards require firmware to operate, it is also recommended that you emerge the linux-firmware ebuild if you have not done so already:

chroot # emerge linux-firmware networkmanager
chroot # rc-update add NetworkManager default

The above command will ensure that NetworkManager starts after you boot into Funtoo Linux. Once you've completed these installation steps and have booted into Funtoo Linux, you can use the nmtui command (which has an easy-to-use console-based interface) to configure NetworkManager so that it will connect (and automatically reconnect, after reboot) to a Wi-Fi access point:

chroot # nmtui

For more information about NetworkManager, see the NetworkManager package page.

Desktop (Wired DHCP)

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 dhcpcd to the default runlevel:

chroot # rc-update add dhcpcd default

When you reboot, dhcpcd will run in the background and manage all network interfaces and use DHCP to acquire network addresses from a DHCP server.

If your upstream DHCP server is dnsmasq, it can be configured to assign addresses via mac address to make servers on DHCP feasible.

Server (Static IP)

For servers, the Funtoo Linux Networking scripts are the supported option for network configuration, and they have their own documentation. 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.

Hostname

By default Funtoo uses "localhost" as hostname. Although the system will work perfectly fine using this name, some ebuilds refuse to install when detecting localhost as hostname. It also may create confusion if several systems use the same hostname. Therefore, it is advised to change it to a more meaningful name. The hostname itself is arbitrary, meaning you can choose almost any combination of characters, as long as it makes sense to the system administrator. To change the hostname, edit

chroot # nano /etc/conf.d/hostname

Look for the line starting with hostname and change the entry between the quotes. Save the file, on the next boot Funtoo will use the new hostname.

   Warning

Hostnames can be up to 63 characters long and may use the following characters: a-z, 0-9 and hyphens (-). However, the hyphen may not be the first or last character.

Install Guide, Chapter 15 < Prev Next >