This document presumes that the user has correctly configured the system's kernel and hardware, and knows the interface name of the hardware. It will also presume that the interface to configure is eth0, which is just as an example as it could also be eno0, ens1, wlan0, enp1s0 etc.
To get started configuring the network card, tell the Gentoo RC system about it. This is done by creating a symbolic link from net.lo to net.eth0 (or whatever the network interface name is on the system) in /etc/init.d.
ln -s net.lo net.eth0
Gentoo's RC system now knows about that interface. It also needs to know how to configure the new interface. All the network interfaces are configured in /etc/conf.d/net. Below is a sample configuration for DHCP and static addresses.
# For DHCP config_eth0="dhcp" # 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 188.8.131.52" # 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 184.108.40.206"
If no configuration is mentioned for an interface then DHCP is assumed.
CIDR stands for Classless InterDomain Routing. Originally, IPv4 addresses were classified as A, B, or C. The early classification system did not envision the massive popularity of the Internet, and is in danger of running out of new unique addresses. CIDR is an addressing scheme that allows one IP address to designate many IP addresses. A CIDR IP address looks like a normal IP address except that it ends with a slash followed by a number; for example, 192.168.0.0/16. CIDR is described in RFC 1519.
Now that the interface is configured, we can start and stop it using the following commands:
When troubleshooting networking, take a look at /var/log/rc.log. Unless the rc_logger variable is set to
NOin /etc/rc.conf, information on the boot activity will be stored in that log file.
Now that the network interface has been successfully stopped and started, the next step is to have it started when Gentoo boots. Here is how to do this.:
rc-update add net.eth0 default
The last rc command instructs Gentoo to start any scripts in the current runlevel that have not yet been started.