Difference between revisions of "Handbook:Parts/Networking/Introduction"

From Gentoo Wiki
Jump to:navigation Jump to:search
(this is not the advanced page)
(Implement suggested changes from Flexibeast (grammar and improved wording))
Line 4: Line 4:
  
 
<!--T:20-->
 
<!--T:20-->
The following networking portion of the handbook describes 'simple' network configuration for systems running the {{Link|OpenRC}} init system utilizing {{Link|1=Netifrc|2=netifrc}} as the network management system.
+
The following portion of the Handbook describes 'simple' network configuration for systems running the {{Link|OpenRC}} init system, utilizing {{Link|Netifrc|netifrc}} as the network management system.
  
 
<!--T:21-->
 
<!--T:21-->
Line 15: Line 15:
 
=== {{Anchor|Creating an interface init script}} Creating an interface init script ===
 
=== {{Anchor|Creating an interface init script}} Creating an interface init script ===
  
In order to manage an interface with netifrc, an ''init script'' for that interface must be created. By default, netifrc installs {{path|/etc/init.d/net.lo}} which can be symlinked to create ''init scripts'' for new interfaces.
+
In order to manage an interface with netifrc, an ''init script'' for that interface must be created. By default, netifrc installs {{Path|/etc/init.d/net.lo}}, which can be symlinked to create ''init scripts'' for new interfaces.
  
 
To create a new init script for interface '''eth0''', simply symlink the default '''net.lo''' script:
 
To create a new init script for interface '''eth0''', simply symlink the default '''net.lo''' script:
Line 21: Line 21:
 
{{RootCmd|prompt=root /etc/init.d #|1=ln -s net.lo net.eth0}}
 
{{RootCmd|prompt=root /etc/init.d #|1=ln -s net.lo net.eth0}}
  
{{Tip|Interface names can be determined by running {{c|ip link show}} ({{c|ip l}} for short) or with {{c|ls /sys/class/net}}.}}
+
{{Tip|Interface names can be determined by running <code>ip link show</code> (<code>ip l</code> for short) or <code>ls /sys/class/net</code>.}}
  
 
{{Important|Interface names will differ from system to system. Kernel based device names starting with '''eth<n>''' or '''wlan<n>''' may differ by index across boots. {{link|udev}} may set interface names starting with '''wlp''' or '''enp''', where these names are persistent across reboots. }}
 
{{Important|Interface names will differ from system to system. Kernel based device names starting with '''eth<n>''' or '''wlan<n>''' may differ by index across boots. {{link|udev}} may set interface names starting with '''wlp''' or '''enp''', where these names are persistent across reboots. }}
Line 47: Line 47:
 
=== {{Anchor|Netifrc interface service management}} Netifrc interface service management ===
 
=== {{Anchor|Netifrc interface service management}} Netifrc interface service management ===
  
With the interface init scripts created, and configuration made, netifrc services can be managed using {{c|rc-service}}. To start '''eth0''':
+
With the interface init scripts created and configured, netifrc services can be managed using {{c|rc-service}}. To start '''eth0''':
  
 
{{RootCmd|rc-service net.eth0 start}}
 
{{RootCmd|rc-service net.eth0 start}}

Revision as of 22:41, 18 October 2024


Warning
Readers should not try to follow instructions directly from the Handbook:Parts namespace (which is THIS page!). The sections displayed below are used as a skeleton for transcluding information into the computer architecture specific handbooks and are therefore lacking critical information.

Please visit the Handbook list to read instructions for a relevant computer architecture.
Parts Handbook
Installation
About the installation
Choosing the media
Configuring the network
Preparing the disks
The stage file
Installing base system
Configuring the kernel
Configuring the system
Installing tools
Configuring the bootloader
Finalizing
Working with Gentoo
Portage introduction
USE flags
Portage features
Initscript system
Environment variables
Working with Portage
Files and directories
Variables
Mixing software branches
Additional tools
Custom package repository
Advanced features
OpenRC network configuration
Getting started
Advanced configuration
Modular networking
Wireless
Adding functionality
Dynamic management


The following portion of the Handbook describes 'simple' network configuration for systems running the OpenRC init system, utilizing netifrc as the network management system.

See also
Readers using systemd should review see the networking portion of the systemd article.

Getting started with netifrc

Netifrc is a simple framework for configuring and managing network interfaces on OpenRC based systems. sys-apps/openrc pulls net-misc/netifrc automatically, as the netifrc USE flag is enabled by default.

Creating an interface init script

In order to manage an interface with netifrc, an init script for that interface must be created. By default, netifrc installs /etc/init.d/net.lo, which can be symlinked to create init scripts for new interfaces.

To create a new init script for interface eth0, simply symlink the default net.lo script:

root /etc/init.d #ln -s net.lo net.eth0
Tip
Interface names can be determined by running ip link show (ip l for short) or ls /sys/class/net.
Important
Interface names will differ from system to system. Kernel based device names starting with eth<n> or wlan<n> may differ by index across boots. udev may set interface names starting with wlp or enp, where these names are persistent across reboots.

Configuring netifrc interfaces

Ethernet interfaces will often work without any additional config, as netifrc will automatically use DHCP for interfaces with no specified config.

If additional configuration is needed, for options such as static IPs, /etc/conf.d/net can be edited:

FILE /etc/conf.d/netSetting a static IP for eth0.
# For static IP using CIDR notation
config_eth0="192.168.0.7/24"
routes_eth0="default via 192.168.0.1"
dns_servers_eth0="192.168.0.1 8.8.8.8"

# For static IP using netmask notation
config_eth0="192.168.0.7 netmask 255.255.255.0"
routes_eth0="default via 192.168.0.1"
dns_servers_eth0="192.168.0.1 8.8.8.8"
Note
If no configuration is specified for an interface, DHCP is used.

Netifrc interface service management

With the interface init scripts created and configured, netifrc services can be managed using rc-service. To start eth0:

root #rc-service net.eth0 start
Important
When troubleshooting networking, take a look at /var/log/rc.log. Unless the rc_logger variable is set to NO in /etc/rc.conf, information on the boot activity will be stored in that log file.

To start eth0 automatically at startup, it can be added to the default runlevel:

root #rc-update add net.eth0 default