10.6.2 High level network configuration using ifupdown
logical interface definitions
In the following it will be important for the reader to understand the
difference between a physical interface and a logical
interface. [
59] A
physical interface is what we have been calling "the
interface", the thing that the kernel names eth0,
eth1, ppp0, or what have you. A
logical interface is a set of values that can be assigned to
the variable parameters of a physical interface. If you find that confusing,
replace the expression "configured as logical interface X"
with the expression "configured with interface profile X"
as you read.
The iface definitions in /etc/network/interfaces
are
actually definitions of logical interfaces, not of physical interfaces. [60] If you never want to
reconfigure your interfaces then you can ignore this fact since the physical
interface foo will by default be configured as logical interface
foo.
However, suppose your computer is a laptop that you transport between home and
work. When you connect the computer to the corporate network or to your home
LAN you need to configure eth0 accordingly.
First define two logical interfaces home and work
(instead of eth0 as we did earlier) which describe how the
interface should be configured for the home network and the work network,
respectively.
iface home inet static
address 192.168.0.123
netmask 255.255.255.0
gateway 192.168.0.1
iface work inet static
address 81.201.3.123
netmask 255.255.0.0
gateway 81.201.1.1
Then physical interface eth0 can be brought up for the home
network with the appropriate configuration by specifying it on the command
line:
# ifup eth0=home
To reconfigure eth0 for the work network issue the commands:
# ifdown eth0
# ifup eth0=work
Note that with the interfaces
file written as above it will no
longer be possible to bring up eth0 by doing ifup
eth0 alone. The reason is that ifup
uses the physical
interface name as the default logical interface name and now in our example no
eth0 logical interface is defined.