HOWTO_Network_profiles_with_arping
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:
- net-misc/iputils
- net-analyzer/arping
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:
- Home: static, IP: 10.0.0.10, gateway: 10.0.0.138
- Work: static, IP: 192.168.10.5, gateway: 192.168.10.1
- DHCP: dynamic, IP: 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
- If you want to have common DNS servers for all profiles use something like this:
dns_servers_eth0=( "208.67.222.222 208.67.220.220" )
- If you experience long DHCP delays include the following if you are using net-misc/dhcpcd in order to reduce the timeout to 5 seconds:
dhcpcd_eth0="-t 5"
- Consider using the following for keeping relevant configuration intact in case DHCP comes into play:
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
- /etc/conf.d/net.example
Created by NickStallman.net, Luxury Homes Australia
Real estate agents should be using interactive floor plans and real estate agent tools.
