It is possible to have a working network stack without resorting to Gentoo net.* scripts at all on simple configuration. Let's agree on what «simple» is:
- only hardware interfaces are needed, i.e. no virtual interfaces;
- IP addresses delivered through DHCP (eventually APIPA)
Basic configuration
Install Roy Marples' dhcpcd with zeroconf support:
Code: Select all
USE=zeroconf emerge -a dhcpcdCode: Select all
# In some cases the loopback interface won't be up, this directive fixes it:
allowinterfaces lo *
# Configure loopback adapter here
interface lo
static ip_address=127.0.0.1/8Code: Select all
rc-update del net.lo boot
rc-update del net.eth0 bootCode: Select all
rc-update add dhcpcd bootIf you installed wpa_supplicant, just add it to the boot runlevel, dhcpcd will detect the interface, whatever it is called and set its IP address automatically. Also note a nice thing Linux does when having wired and wireless interfaces together on the same network is that the one with the lowest metric takes precedence over existing connections.
Suppose for instance you have an ongoing transfer of a very large file over your wireless interface to an existing network mountpoint. Plug the cable and wait for dhcpcd to set the IP address of the ethernet interface and you'll see the network activity switch to the fastest interface. You don't even need to interrupt and restart the transfer. That feature comes handy when you cannot bond interfaces, especially with wireless.
VPN interfaces
Now dhcpcd will attach to any visible network interface and assign an IP address whenever it can as soon as it discovers one (it dynamically detects them). If you have VPN interfaces dhcpcd will also interfere, which is probably not what you want. You can either constraint dhcpcd to a list of interfaces:
Code: Select all
allowinterfaces eth* wlan0Code: Select all
denyinterfaces ppp0 en*DNS resolution
Your VPN might be configured with the USEPEERDNS parameter, which affects how DNS resolution works. In general it's a good idea to leave it as it is since being connected to the internet *and* to a private network creates a security hole if traffic is also routed outside the VPN. However if you know what you're doing and still want DNS resolution while using your remote network, here's what to do.
Install dnsmasq and openresolv and create a directory to store name service resolvers for dnsmasq, openresolv will update them as soon as VPN interfaces are created using the remote DNS IP addresses. For instance I stored those files in /etc/dnsmasq.d/ .
Code: Select all
# mkdir /etc/dnsmasq.d
# rc-update add dnsmasq bootCode: Select all
# Configuration for resolvconf(8)
# See resolvconf.conf(5) for details
resolv_conf=/etc/resolv.conf
dnsmasq_conf=/etc/dnsmasq.d/openresolv.conf
dnsmasq_resolv=/etc/dnsmasq.d/resolv.conf
# If you run a local name server, you should uncomment the below line and
# configure your subscribers configuration files below.
name_servers=127.0.0.1Code: Select all
resolv-file=/etc/dnsmasq.d/resolv.conf
conf-file=/etc/dnsmasq.d/openresolv.confCode: Select all
touch /etc/dnsmasq.d/openresolv.conf
touch /etc/dnsmasq.d/resolv.confUpdate, October 2014: The loopback interface is no longer up by default and needs to be somehow. By default dhcpcd doesn't bring the loopback interface up unless instructed to, which is why dhcpcd.conf now includes this line:
Code: Select all
allowinterfaces lo *




