Gentoo networking can work in the live installer while the installed system still has no interface service for the next boot. On OpenRC systems, netifrc reads /etc/conf.d/net and starts one net.enp1s0-style service per interface, so the interface name, config variable names, and boot runlevel entry all have to match.
The example configuration uses a wired interface named enp1s0 with a static IPv4 address through netifrc. Replace the interface name, address, prefix, gateway, and DNS servers with values from the target network. DHCP uses the same service setup with config_enp1s0="dhcp" and a DHCP client such as net-misc/dhcpcd.
Use one network manager for the interface. If NetworkManager, systemd-networkd, a standalone dhcpcd service, or another daemon already owns the same device, choose one manager before adding netifrc to the default runlevel.
Related: How to enter a Gentoo chroot
Related: How to enable a service on Gentoo with OpenRC
When using live media, enter the installed root first so /etc/conf.d/net and /etc/init.d are written in the target Gentoo system. Related: How to enter a Gentoo chroot
# ip link show
Use the real interface name from the output, such as enp1s0, eno1, or eth0. The name must be used in both /etc/conf.d/net variables and the net.enp1s0 service name.
# emerge --ask --noreplace net-misc/netifrc sys-apps/iproute2
Current OpenRC stage3 systems normally include netifrc. Install net-misc/dhcpcd as well when the interface will use config_enp1s0="dhcp".
# nano /etc/conf.d/net
config_enp1s0="198.51.100.10/24" routes_enp1s0="default via 198.51.100.1" dns_servers_enp1s0="198.51.100.53 198.51.100.54"
For DHCP, replace the block with config_enp1s0="dhcp" and omit static route and DNS lines unless the network needs overrides.
Changing the active network interface can interrupt remote sessions. Keep console access or another recovery path available before restarting netifrc on a remote host.
# sh -n /etc/conf.d/net
No output means the file parsed successfully as shell syntax. This does not prove that the address, gateway, or interface name is correct.
# ln -s /etc/init.d/net.lo /etc/init.d/net.enp1s0
Skip this command when /etc/init.d/net.enp1s0 already exists and points to /etc/init.d/net.lo.
# rc-update add net.enp1s0 default * service net.enp1s0 added to runlevel default
# rc-service net.enp1s0 start
# rc-service net.enp1s0 status * status: started
# ip address show dev enp1s0
The output should contain inet 198.51.100.10/24 when using the static example above. For DHCP, confirm that the address belongs to the expected network.
# ip route show default
The static example should report a default route through 198.51.100.1 on enp1s0. For DHCP, confirm that the route came from the expected network.