Handbook:SPARC/Networking/Introduction
Следующая часть руководства описывает «продвинутую» настройку сети для систем, работающих под управлением системы инициализации OpenRC, используя netifrc в качестве системы управления сетью.
Для систем, работающих под управлением systemd, читателям следует ознакомиться с частью по настройке сети статьи systemd.
Приступаем к настройке при помощи 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.
Создание init-сценария интерфейса
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.eth0Interface names can be determined by running
ip link show (ip l for short) or ls /sys/class/net.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.
Конфигурация интерфейсов в netifrc
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:
/etc/conf.d/netУстановка статического IP-адреса для eth0.# Для статического адреса в нотации CIDR 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" # Для статического IP-адреса в нотации сетевой маски 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"
If no configuration is specified for an interface, DHCP is used.
Управление службами интерфейсов в netifrc
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При поиске неисправностей сети взгляните на /var/log/rc.log. В данном лог файле можно найти информацию об активности при загрузке системы, если только переменная rc_logger не установлена в значение
NO в файле /etc/rc.conf.To start eth0 automatically at startup, it can be added to the default runlevel:
root #rc-update add net.eth0 default