We now support modular networking scripts, which means we can easily add support for new interface types and configuration modules while keeping compatibility with existing ones.
Modules load by default if the package they need is installed. If you specify a module here that doesn't have its package installed then you get an error stating which package you need to install. Ideally, you only use the modules setting when you have two or more packages installed that supply the same service and you need to prefer one over the other.
# Prefer ifconfig over iproute2 modules="ifconfig"# You can also specify other modules for an interface # In this case we prefer pump over dhcpcd modules_eth0="pump"# You can also specify which modules not to use - for example you may be # using a supplicant or linux-wlan-ng to control wireless configuration but # you still want to configure network settings per ESSID associated with. modules="!iwconfig"
We provide two interface handlers presently:
# emerge sys-apps/iproute2# To prefer ifconfig over iproute2 if both are installed as openrc prefers # to use iproute2 then modules="ifconfig"
As both
config_eth0="192.168.0.2/24" config_eth0="192.168.0.2 netmask 255.255.255.0"# We can also specify broadcast config_eth0="192.168.0.2/24 brd 192.168.0.255" config_eth0="192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
DHCP is a means of obtaining network information (IP address, DNS servers, Gateway, etc) from a DHCP server. This means that if there is a DHCP server running on the network, you just have to tell each client to use DHCP and it sets up the network all by itself. Of course, you will have to configure for other things like wireless, PPP or other things if required before you can use DHCP.
DHCP can be provided by
| DHCP Module | Package | Pros | Cons |
|---|---|---|---|
If you have more than one DHCP client installed, you need to specify which one
to use - otherwise we default to
To send specific options to the DHCP module, use
We try and make DHCP relatively agnostic - as such we support the following
commands using the
# Only needed if you have more than one DHCP module installed modules="dhcpcd" config_eth0="dhcp" dhcpcd_eth0="-t 10"# Timeout after 10 seconds dhcp_eth0="release nodns nontp nonis"# Only get an address
First we need to install the ADSL software.
# emerge net-dialup/ppp
Second, create the PPP net script and the net script for the ethernet interface to be used by PPP:
# ln -s /etc/init.d/net.lo /etc/init.d/net.ppp0 # ln -s /etc/init.d/net.lo /etc/init.d/net.eth0
Be sure to set
Now we need to configure
config_eth0=null(Specify your ethernet interface) config_ppp0="ppp" link_ppp0="eth0"(Specify your ethernet interface) plugins_ppp0="pppoe" username_ppp0='user' password_ppp0='password' pppd_ppp0=" noauth defaultroute usepeerdns holdoff 3 child-timeout 60 lcp-echo-interval 15 lcp-echo-failure 3 noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp" rc_need_ppp0="net.eth0"
You can also set your password in
# The * is important "username" * "password"
If you use PPPoE with a USB modem you'll need to emerge
APIPA tries to find a free address in the range 169.254.0.0-169.254.255.255 by arping a random address in that range on the interface. If no reply is found then we assign that address to the interface.
This is only useful for LANs where there is no DHCP server and you don't connect directly to the internet and all other computers use APIPA.
For APIPA support, emerge
# Try DHCP first - if that fails then fallback to APIPA config_eth0="dhcp" fallback_eth0="apipa"# Just use APIPA config_eth0="apipa"
For link bonding/trunking emerge
Bonding is used to increase network bandwidth. If you have two network cards going to the same network, you can bond them together so your applications see just one interface but they really use both network cards.
# To bond interfaces together slaves_bond0="eth0 eth1 eth2"# You may not want to assign an IP to the bonded interface config_bond0="null"# Depend on eth0, eth1 and eth2 as they may require extra configuration rc_need_bond0="net.eth0 net.eth1 net.eth2"
For bridging support emerge
Bridging is used to join networks together. For example, you may have a server that connects to the internet via an ADSL modem and a wireless access card to enable other computers to connect to the internet via the ADSL modem. You could create a bridge to join the two interfaces together.
# Configure the bridge - "man brctl" for more details brctl_br0="setfd 0" "sethello 0" "stp off"# To add ports to bridge br0 bridge_br0="eth0 eth1"# You need to configure the ports to null values so dhcp does not get started config_eth0="null" config_eth1="null"# Finally give the bridge an address - you could use DHCP as well config_br0="192.168.0.1/24"# Depend on eth0 and eth1 as they may require extra configuration rc_need_br0="net.eth0 net.eth1"
If you need to, you can change the MAC address of your interfaces through the network configuration file too.
# To set the MAC address of the interface mac_eth0="00:11:22:33:44:55"# To randomize the last 3 bytes only mac_eth0="random-ending"# To randomize between the same physical type of connection (e.g. fibre, # copper, wireless) , all vendors mac_eth0="random-samekind"# To randomize between any physical type of connection (e.g. fibre, copper, # wireless) , all vendors mac_eth0="random-anykind"# Full randomization - WARNING: some MAC addresses generated by this may # NOT act as expected mac_eth0="random-full"
You don't need to emerge anything for tunnelling as the interface handler can do it for you.
# For GRE tunnels iptunnel_vpn0="mode gre remote 207.170.82.1 key 0xffffffff ttl 255"# For IPIP tunnels iptunnel_vpn0="mode ipip remote 207.170.82.2 ttl 255"# To configure the interface config_vpn0="192.168.0.2 peer 192.168.1.1"
For VLAN support, emerge
Virtual LAN is a group of network devices that behave as if they were connected to a single network segment - even though they may not be. VLAN members can only see members of the same VLAN even though they may share the same physical network.
# Specify the VLAN numbers for the interface like so # Please ensure your VLAN IDs are NOT zero-padded vlans_eth0="1 2"# You can also configure the VLAN # see for vconfig man page for more details vconfig_eth0="set_name_type VLAN_PLUS_VID_NO_PAD" vconfig_vlan1="set_flag 1" "set_egress_map 2 6"# Configure the interface as usual config_vlan1="172.16.3.1 netmask 255.255.254.0" config_vlan2="172.16.2.1 netmask 255.255.254.0"