Search:  
Gentoo Wiki

Network_profiles

Contents

Introduction

This article is mainly for users that use portable computers and need to adjust their network configuration very often, depending on the network they want to connect.

Required software

In order to achieve this you need to emerge the following:

Emerge them:

emerge iputils arping

Configuration

Edit /etc/conf.d/net using your favorite editor. Consider the following scenario. You want to create three network profiles, one for your home network, one for your work network and one that will handle networks with DHCP:

This is what your configuration should look like:

# Enable arping mode
config_eth0=( "arping" )
# Define the gateways you want to configure
# You can consider each gateway as a profile
gateways_eth0="192.168.10.1 10.0.0.138"
# Define the IP and netmask when using gateway 10.0.0.138
config_010000000138=( "10.0.0.10/24" )
# Define the default route for gateway 10.0.0.138
routes_010000000138=( "default via 10.0.0.138" )
# Define the DNS servers to use with gateway 10.0.0.138
dns_servers_010000000138=( "164.34.23.45 145.56.34.56" )
# Define the IP and netmask when using gateway 192.168.10.1
config_192168010001=( "192.168.10.5/24" )
# Define the default route for gateway 192.168.10.1
routes_192168010001=( "default via 192.168.10.1" )
# Define the DNS servers to use with gateway 192.168.10.1
dns_servers_192168010001=( "192.168.0.1" )
# If any of the above profiles fail use DHCP
fallback_eth0=( "dhcp" )

Tips

dns_servers_eth0=( "208.67.222.222 208.67.220.220" )
dhcpcd_eth0="-t 5"
dhcp_eth0="nodns nontp nonis"

Same Gateway on Different Networks

In case different networks use the same gateway, you can include a specific MAC address for each gateway. For example, I use a laptop to connect to different networks, and it might be the case that another network has the same gateway that my home network. In that case, I use the MAC address of my home router (00:14:BF:F6:F0:FB) to give my laptop a particular IP address (192.168.1.102) in my home network.

gateways_eth0="192.168.1.1,00:14:BF:F6:F0:FB"
config_192168001001_0014BFF6F0FB=( "192.168.1.102/24" )
routes_192168001001_0014BFF6F0FB=( "default via 192.168.1.1" )
dns_servers_192168001001_0014BFF6F0FB=( "192.168.1.1" )

References

Retrieved from "http://www.gentoo-wiki.info/Network_profiles"

Last modified: Wed, 20 Aug 2008 06:28:00 +0000 Hits: 8,649