Differences between revisions 57 and 58
Revision 57 as of 2008-02-08 14:25:43
Size: 40520
Editor: OsamuAoki
Comment:
Revision 58 as of 2008-02-08 14:43:33
Size: 40553
Editor: OsamuAoki
Comment:
Deletions are marked like this. Additions are marked like this.
Line 503: Line 503:
{i} The state of the switchable {{{ifupdown}}} system can be checked by the "{{{cat /etc/network/run/ifstate}}}" command. {i} The assigned '''network configuration''' values for all the '''network interfaces''' are listed by the "{{{cat /etc/network/run/ifstate}}}" command.

Do not use Edit(GUI) button.

?TableOfContents(4)

Copyright 2007 Osamu Aoki GPL, (Please agree to GPL, GPL2, and any version of GPL which is compatible with DSFG if you update any part of wiki page)

The network

This section will address network setup for the mobile PC which moves around different networks. (For the non-mobile PC, the debian-installer should have taken care your network setup and there are almost nothing for us to play with.)

You should install the resolvconf package for the mobile PC. This package provides framework to solve conflicts of the host address resolution between different network configuration scripts when network configuraion changes. Read more on /usr/share/doc/resolvconf/README.Debian.

For the fixed location server machine, you can do without the resolvconf package and keep your system simple.

In this document, we focus on Debian-specific issues. For a general guide to GNU/Linux networking, read the [http://www.tldp.org/LDP/nag2/ Linux Network Administrators Guide].

The basic network infrastructures

Let's review the basic network infrastructure of the modern Debian system.

The domain name

The naming for the domain name is a tricky one for the normal workstation PC users. The PC workstation may be mobile one hopping around the network or located behind the NAT firewall inaccessible from the Internet. For such case, you do not want the domain name to be a valid domain name to avoid name collision.

According to [http://tools.ietf.org/html/rfc2606 rfc2606], "invalid" seems to be a choice for the top level domain (TLD) to construct domain names that are sure to be invalid from the Internet.

The [http://en.wikipedia.org/wiki/MDNS mDNS] network discovery protocol ([http://en.wikipedia.org/wiki/Bonjour_(software) Apple Bonjour / Apple Rendezvous], Avahi on Debian) uses [http://en.wikipedia.org/wiki/.local "local"] as the [http://en.wikipedia.org/wiki/Pseudo-top-level_domain pseudo-top-level domain]. [http://support.microsoft.com/kb/296250 Microsoft also seem to promote "local" for the TLD of local area network].

Other popular choices for the invalid TLD seem to be "localdomain", "lan", "localnet", or "home" according to my incoming mail analysis.

The host name resolution

The host name resolution is currently supported by the NSS (Name Service Switch) mechanism too. The flow of this resolution is:

  1. The /etc/nsswitch.conf file with stanza like "hosts: files dns" dictates the host name resolution order. (This replaces the old functionality of the "order" stanza in /etc/host.conf.)

  2. The files method is invoked first. If the host name is found in the /etc/hosts file, it returns all valid addresses for it and exits. (The /etc/host.conf file contains "multi on".)

  3. The dns method is invoked. If the host name is found by the query to the Internet Domain Name System (DNS) identified by the /etc/resolv.conf file, it returns all valid addresses for it and exits.

The /etc/hosts file [http://bugs.debian.org/316099 associates IP addresses with hostnames]:

127.0.0.1 localhost
127.0.1.1 <host_name>.<domain_name> <host_name>

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Here the <host_name> in this configuration matches the PC's own host name defined in the /etc/hostname. I tend to use bogus domain name for <domain_name>, such as "invalid" in this configuration for the mobile PC.

The /etc/resolv.conf is a static file if the resolvconf package is not installed. If installed, it is a symbolic link. Either way, it contains information that initialize the resolver routines. If the DNS is found at IP="192.168.11.1", it contains:

nameserver 192.168.11.1

The host name resolution via Multicast DNS (using [http://en.wikipedia.org/wiki/Zeroconf Zeroconf], aka [http://en.wikipedia.org/wiki/Bonjour_(software) Apple Bonjour / Apple Rendezvous]) which effectively allows name resolution by common Unix/Linux programs in the ad-hoc mDNS domain "local", can be provided by installing the libnss-mdns package. The /etc/nsswitch.conf file should have stanza like "hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4" to enable this functionality.

The network interface name

The network interface name, e.g. eth0, is assigned to each hardware in the Linux kernel through the user space configuration mechanism, udev (see: @{@theudevsystem@}@), as it is found. The network interface name is referred as physical interface in the manpage of ifup(8) and interfaces(5).

In order to ensure each network interface to be named persistently for each reboot using MAC address etc., there is a record file "/etc/udev/rules.d/z25_persistent-net.rules". This file is automatically generated by the "/lib/udev/write_net_rules" program, probably run by the "persistent-net-generator.rules" rules file. You can modify it to change naming rule.

<!> When editing the "persistent-net-generator.rules" rules file, you must keep each rule on a single line and the MAC address in lowercase. For example, if you find "Firewire device" and "PCI device" in this file, you probably want to name "PCI device" as eth0 and configure it as the primary network interface.

The network address range for the LAN

Let us be reminded of the IPv4 32 bit address ranges in each class reserved for use on the local area networks (LANs) by [http://tools.ietf.org/html/rfc1918 rfc1918]. These addresses are guaranteed not to conflict with any addresses on the Internet proper.

List of network address ranges.

Class

network addresses

net mask

net mask /bits

# of subnets

A

10.x.x.x

255.0.0.0

/8

1

B

172.16.x.x -- 172.31.x.x

255.255.0.0

/16

16

C

192.168.0.x -- 192.168.255.x

255.255.255.0

/24

256

(!) If one of these addresses is assigned to a host, then that host must not access the Internet directly but must access it through a gateway that acts as a proxy for individual services or else does Network Address Translation(NAT). The broadband router usually performs NAT for the consumer LAN environment.

The network configuration infrastructure

The network configuration tools can be classified into several levels.

List of network configuration tools.

1

2

3

packages

popcon

size

level

function

ifplugd

571

-

Higher

Manage the wired network automatically

waproamd

141

-

, ,

Manage the wireless network automatically

network-manager

14064

-

, ,

Manage the network with GUI

ifupdown

35032

-

Middle

Standardized level to bring up and down the network

guessnet

112

-

, ,

Helper script to enhance "ifupdown" package via /etc/network/interfaces file

ifupdown-extra

--

-

, ,

Network testing script to enhance "ifupdown" package

ifupdown-scripts-zg2

--

-

, ,

Zugschlus' interface scripts for ifupdown's manual method

iptables

-

-

Lower

Administration tools for packet filtering and NAT

net-tools

36300

-

, ,

The NET-3 networking toolkit (IPv4 network configuration)

iproute

19172

-

, ,

IPv6 and other advanced network configuration

dhcp3-client

20532

-

, ,

DHCP client

wpasupplicant

-

-

, ,

Client support for WPA and WPA2 (IEEE 802.11i)

wireless-tools

-

-

, ,

Tools for manipulating Linux Wireless Extensions

ppp

4638

-

, ,

PPP/PPPoE connection with chat

pppoeconf

566

-

, ,

Configuration helper for PPPoE connection

pppconfig

559

-

, ,

Configuration helper for plain PPP connection with chat

wvdial

224

-

, ,

PPP connection with wvdial with ppp, configuration helper

iputils-ping

-

-

Test

Tools to test the reachability of network hosts

traceroute

-

-

, ,

Traces the route taken by packets over an IPv4/IPv6 network

dnsutils

-

-

, ,

Network clients provided with BIND

dlint

-

-

, ,

Checks dns zone information using nameserver lookups

In this document, we focus on managing the network using middle level tools, i.e. the ifupdown package while supplementing it with useful lower level tools. ifupdown is the standard way to manage network interfaces in Debian.

The network connection

FIXME: Since my MacBook has no build-in modem, and I use the broadband-modem via ethernet, all POTS-related description needs to be tested with the recent system.

The typical network connection type and connection path for a PC can be summarized as:

List of network connection types and connection paths.

PC

connection type

connection path

Serial port (ppp0)

PPP

<=> modem <=> POTS <=> dial-up access point <=> ISP

Ethernet port (eth0)

PPPoE/DHCP/Static

<=> BB-modem <=> BB service <=> BB access point <=> ISP

Ethernet port (eth0)

DHCP/Static

<=> LAN <=> BB-router (<=> BB-modem ...)

Here is the summary of configuration script for each connection type:

List of network connection configurations.

connection type

configuration

backend package(s)

PPP

pppconfig to create deterministic chat

pppconfig, ppp

PPP (alternative)

wvdialconf to create heuristic chat

ppp, wvdial

PPPoE

pppoeconf to create deterministic chat

pppoeconf, ppp

DHCP

described in /etc/dhcp3/dhclient.conf

dhcp3-client

static IP (IPv4)

described in /etc/network/interfaces

net-tools

static IP (IPv6)

described in /etc/network/interfaces

iproute

The network connection acronyms mean:

List of network connection acronyms.

acronym

meaning

[http://en.wikipedia.org/wiki/Plain_old_telephone_service POTS]

The plain old telephone service

BB

The [http://en.wikipedia.org/wiki/Broadband broadband]

BB-service

E.g., the digital subscriber line (DSL), the cable TV, or the fiber to the premises (FTTP).

[http://en.wikipedia.org/wiki/LAN LAN]

The local area network

[http://en.wikipedia.org/wiki/DHCP DHCP]

The dynamic host configuration protocol

[http://en.wikipedia.org/wiki/Point-to-Point_Protocol PPP]

The point-to-point protocol

[http://en.wikipedia.org/wiki/Pppoe PPPoE]

The point-to-point protocol over Ethernet

[http://en.wikipedia.org/wiki/ISP ISP]

The Internet service provider

The DHCP connection with the Ethernet

Just install the dhcp3-client package for the Ethernet served by the [http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol dynamic host configuration protocol (DHCP)].

The static IP connection with the Ethernet

No special action is needed for the Ethernet served by the static IP.

The PPP connection with pppconfig

The configuration script pppconfig will configure the PPP connection interactively just by selecting:

  • the telephone number,
  • the ISP user name,
  • the ISP password,
  • the port speed,
  • the modem communication port, and
  • the authentication method.

The configuration files are:

List of configuration files for the PPP connection with pppconfig.

file

function

/etc/ppp/peers/<isp_name>

The pppconfig generated configuration file for pppd specific to <isp_name>

/etc/chatscripts/<isp_name>

The pppconfig generated configuration file for chat specific to <isp_name>

/etc/ppp/options

The general execution parameter for pppd

/etc/ppp/pap-secret

Authentication data for the PAP (still used)

/etc/ppp/chap-secret

Authentication data for the CHAP (more secure)

<!> The "<isp_name>" value of "provider" is assumed if pon and poff commands are invoked without arguments.

You can test configuration using lower level network configuration tools:

$ sudo pon <isp_name>
...
$ sudo poff <isp_name>

See /usr/share/doc/ppp/README.Debian.gz for more information.

The alternative PPP connection with wvdialconf

A different approach to using pppd is to run it from wvdial which comes in the wvdial package. Instead of pppd running chat to dial in and negotiate the connection, wvdial does the dialing and initial negotiating and then starts pppd to do the rest.

The configuration script wvdialconf will configure the PPP connection interactively just by selecting:

  • the telephone number,
  • the ISP user name, and
  • the ISP password.

The wvdial succeeds in making the connection in most cases and maintains authentication data list automatically.

The configuration files are:

List of configuration files for the PPP connection with wvdialconf.

file

function

/etc/ppp/peers/wvdial

The wvdialconf generated configuration file for pppd specific to wvdial

/etc/wvdial.conf

The wvdialconf generated configuration file

/etc/ppp/options

The general execution parameter for pppd

/etc/ppp/pap-secret

Authentication data for the PAP (still used)

/etc/ppp/chap-secret

Authentication data for the CHAP (more secure)

You can test configuration using lower level network configuration tools:

$ sudo wvdial
...
$ sudo killall wvdial

See manpages of wvdial(1), wvdial.conf(5) for more information.

The PPPoE connection with pppoeconf

The PPPoE stand for PPP over Ethernet. The configuration script pppoeconf will configure the PPPoE connection interactively.

The configuration files are:

List of configuration files for the PPP connection with pppoeconf.

file

function

/etc/ppp/peers/dsl-provider

The pppoeconf generated configuration file for pppd specific to pppoe

/etc/ppp/options

The general execution parameter for pppd

/etc/ppp/pap-secret

Authentication data for the PAP (still used)

/etc/ppp/chap-secret

Authentication data for the CHAP (more secure)

You can test configuration using lower level network configuration tools:

$ sudo pon dsl-provider
...
$ sudo poff dsl-provider

See /usr/share/doc/pppoeconf/README.Debian for more information.

The basic network configuration with ifupdown

The ifupdown package provides standardized middle level for the network configuration in the Debian system. Let us learn this with simplified introduction and many typical examples.

The command syntax simplified

The ifupdown package provides a nice set of abstractions for network configuration and offers very intuitive commands to the user.

List of network configuration commands with ifupdown.

command

action

ifup eth0=config1

To bring up a network interface eth0 with the configuration config1.

ifdown eth0=config1

To bring down a network interface eth0 with the configuration config1.

ifup eth0

To bring up a network interface eth0 with the configuration eth0 if "iface eth0" stanza exists.

, ,

To bring up a network interface eth0 with the configuration selected by mapping stanza if glob matches.

ifdown eth0

To bring down a network interface eth0 with the configuration eth0 if "iface eth0" stanza exists.

, ,

To bring down a network interface eth0 with the configuration selected by mapping stanza if glob matches.

The configuration file /etc/network/interfaces (/e/n/i as its acronym in the following text) dictates the actual behavior of above commands. We will explain its syntax including "mapping" stanza later.

This intuitive syntax of assigning the network configuration name to the network interface name is described in the manpage of ifup(8) and ifdown(8) with the slightly different terminology.

List of terminology for network devices.

manpage terminology

my terminology

explanation

examples in the following text

physical interface name

network interface name

A name given by the Linux kernel using udev mechanism.

lo, eth0, <interface_name>

logical interface name

network configuration name

A name token following iface in the /e/n/i.

config1, config2, <config_name>

I hope you get roughly what these words mean and how the terminology works. We will get to the detail by the examples.

The basic syntax of /etc/network/interfaces

The key syntax of /e/n/i as explained in the manpage interfaces(5) can be summarized as:

List of stanzas in /e/n/i

stanza

meaning

"auto <interface_name>"

To start interface <interface_name> upon start of the system.

"allow-hotplug <interface_name>"

To start interface <interface_name> when the kernel detects a hotplug event from the interface.

"iface <config_name> ..."

To define the network configuration <config_name>.

Lines started with "mapping <interface_name_glob> "

To define mapping value of <config_name> for the matching <interface_name>.

A line starting with a hash "#"

To be ignored as comments. (end-of-line comments are not supported)

A line ending with a backslash "\"

To extend the configuration to the next line.

The "mapping" stanza has the following syntax:

mapping <interface_name_glob>
 script <script_name>
 map <script_input1>
 map <script_input2>
 map <script_input3>

If the "<interface_name_glob>" matches "eth0", the execution of

$ sudo ifup eth0

will produce the execution of:

$ sudo ifup eth0=$(echo -e '<script_input1> \n <script_input2> \n <script_input3>' | <script_name> eth0)

to configure eth0 automatically. Here, lines with "map" are optional and can be repeated.

(!) The glob for mapping stanza works like shell file name glob.

The caution for using ifupdown

The standard process of activating an interface with the ifupdown package involves:

  • execution of "ifup <interface_name>" command,

  • trigger by "auto <interface_name>" stanza in /e/n/i, or

  • trigger by "allow-hotplug <interface_name>" stanza in /e/n/i.

While an interface is activated by the ifupdown package, tweaking this interface with the lower level network configuration tool or editing /e/n/i file will cause interferences and problems. You must issue "ifdown <interface_name>" command first to deactivate it.

The loopback network interface

The following configuration entry in the /e/n/i file brings up the loopback network interface lo upon booting the system (via auto stanza).

auto lo
iface lo inet loopback

The network interface served by the DHCP

The typical modern home and small business network, i.e. LAN, are connected to the WAN(Internet) using some consumer grade broadband router. The LAN behind this router is usually served by the [http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol dynamic host configuration protocol (DHCP)] server running on the router.

The following configuration entry in the /e/n/i file is the typical way to set up a network interface in such an environment. When the Linux kernel detects the physical interface eth0, the allow-hotplug stanza will cause ifup to bring up the interface and the iface stanza will cause ifup to use DHCP to configure the interface.

allow-hotplug eth0
iface eth0 inet dhcp

The network interface with the static IP

The following configuration entry in the /e/n/i file brings up the primary network interface eth0 upon the Linux kernel finding up the physical interface eth0 (via allow-hotplug stanza) with the static IP:

allow-hotplug eth0
iface eth0 inet static
 address 192.168.11.100
 netmask 255.255.255.0
 broadcast 192.168.11.255
 gateway 192.168.11.1
 dns-domain lan
 dns-nameservers 192.168.11.1

Here, I assumed:

  • IP address range of the LAN network: 192.168.11.0 - 192.168.11.255

  • IP address of the gateway: 192.168.11.1

  • IP address of the PC: 192.168.11.100

  • The resolvconf package is installed.

  • The domain name as "lan".

  • The DNS server at: 192.168.11.1

When the resolvconf package is not installed, DNS related configuration needs to be done manually by editing the /etc/resolv.conf as:

nameserver 192.168.11.1 
domain lan

<!> The IP addresses used in the above example are not meant to be copied literally. You have to adjust numbers to your actual network configuration.

The wireless LAN interface

The wireless LAN (WLAN for short) provides the fast wireless connectivity through the spread-spectrum communication of unlicensed 2.4 (802.11b/g) and 5 GHz (802.11a/h) radio bands, with an 11 Mbps (802.11b) or 54 Mbps (802.11a or g) data rate or with products that contain both bands (dual band).

The WLAN interfaces are almost like normal Ethernet interfaces but require some network ID and encryption key data to be provided when they are initialized. The higher level network tools are exactly the same as the Ethernet except the interface names are a bit different like ath0, wlan0, ath0, wifi0, ... depending on the kernel drivers used.

Here are some keywords to remember for the WLAN:

List of acronyms for WLAN.

acronym

full word

meaning

NWID

Network ID

The 16 bit network ID used by pre-802.11 network. Very much deprecated.

(E)SSID

(Extended) Service Set Identifier

The network name of the Access Points (APs) interconnected to form an integrated 802.11 wireless LAN. Domain ID.

WEP, (WEP2)

Wired Equivalent Privacy

The 1st generation 64-bit (128-bit) wireless encryption standard with 40-bit key. Deprecated.

WPA

Wi-Fi Protected Access

The 2nd generation wireless encryption standard (most of 802.11i), compatible with WEP.

WPA2

Wi-Fi Protected Access 2

The 3rd generation wireless encryption standard (full 802.11i), non-compatible with WEP.

The actual choice of protocol is usually limited by the wireless router you deploy.

The wireless LAN interface with the WEP

You need to install the wireless-tools package to support the WLAN with the old WEP. (Your consumer grade router may still be using. Insecure infrastructure but better than nothing.)

<!> Please note that your network traffic on WLAN may be sniffed by others.

In case of the [http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol DHCP] served IP on WLAN connection, the /e/n/i file entry should be:

allow-hotplug eth0
iface eth0 inet dhcp
 wireless-essid Home
 wireless-key1 0123-4567-89ab-cdef
 wireless-key2 12345678
 wireless-key3 s:password
 wireless-defaultkey 2
 wireless-keymode open

See more on /usr/share/doc/wireless-tools/README.Debian.

The wireless LAN interface with the WAP/WAP2

You need to install the wpasupplicant package to support the WLAN with the new WAP/WAP2.

In case of the DHCP served IP on WLAN connection provided by the the madwifi driver backend, the /e/n/i file entry should be:

allow-hotplug ath0
iface ath0 inet dhcp
 wpa-driver madwifi
 wpa-ssid homezone
 # hexadecimal psk is encoded from a plaintext passphrase
 wpa-psk 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f

See more on /usr/share/doc/wpasupplicant/README.modes.gz.

The PPP connection

You need to configure the PPP connection first as described before. Then, add the /e/n/i file entry for the primary PPP device ppp0 as:

allow-hotplug eth0
iface ppp0 inet ppp
 provider <isp_name>

The alternative PPP connection

You need to configure the alternative PPP connection with wvdial first as described before. Then, add the /e/n/i file entry for the primary PPP device ppp0 as:

allow-hotplug eth0
iface ppp0 inet wvdial

The PPPoE connection

You need to configure the PPPoE connection first as described before. Then, add the /e/n/i file entry for the primary PPPoE device eth0 as:

allow-hotplug eth0
iface eth0 inet ppp
 provider dsl-provider

The manually switchable network configuration

In case of you wishing to switch among several network configurations, e.g. the static IP, DHCP served IP, and PPPoE connected IP, the /e/n/i should be:

auto lo
iface lo inet loopback

iface config1 inet dhcp

iface config2 inet static
 address 192.168.11.100
 netmask 255.255.255.0
 broadcast 192.168.11.255
 gateway 192.168.11.1
 dns-domain lan
 dns-nameservers 192.168.11.1

iface pppoe inet ppp
 provider dsl-provider

Please note the token after iface does not use the network interface name. Also, there are no auto stanza nor allow-hotplug stanza to start the network interface eth0.

Now you are ready to switch the network configuration.

Let's move your PC to a LAN served by the DHCP. You bring up the network interface (the physical interface) eth0 by assigning the network configuration name (the logical interface name) config1 to it:

$ sudo ifup eth0=config1
Password:
...

The interface eth0 is up, configured by DHCP and connected to LAN.

$ sudo ifdown eth0=config1
...

The interface eth0 is down and disconnected from LAN.

Let's move your PC to a LAN served by the static IP. You bring up the network interface eth0 by assigning the network configuration name config2 to it:

$ sudo ifup eth0=config2
...

The interface eth0 is up, configured with static IP and connected to LAN. The additional parameters given as dns-* configures /etc/resolv.conf contents. This /etc/resolv.conf is better maneged if the resolvconf package is installed.

$ sudo ifdown eth0=config2
...

The interface eth0 is down and disconnected from LAN, again.

Let's move your PC directly connected to BB-modem connected to the PPPoE served service. You bring up the network interface eth0 by assigning the network configuration name pppoe to it:

$ sudo ifup eth0=pppoe
...

The interface eth0 is up, configured with PPPoE connection directly to the ISP.

$ sudo ifdown eth0=pppoe
...

The interface eth0 is down and disconnected, again.

{i} The assigned network configuration values for all the network interfaces are listed by the "cat /etc/network/run/ifstate" command.

The troubled network connection recovery

The ifupdown package normally starts the network interface triggered by the auto stanza or allow-hotplug stanza. If the interface, e.g. eth0, has some issues such as the case when the wire to the Ethernet port is unplugged while device is activated, the interface becomes activated without the proper network configuration. You can check this situation with the "ifconfig eth0" command. The normal output lines as the following are missing in the output for such a case.

          inet addr:192.168.11.2  Bcast:192.168.11.255  Mask:255.255.255.0
          inet6 addr: fe80::219:e3ff:fe63:e3f/64 Scope:Link

You can fix this situation by plugging the wire back to the Ethernet port and retart the interface:

$ sudo ifdown eth0; sudo ifup eth0

The advanced network configuration with ifupdown

There are some spaces for improvement beyond what was described in @{@thebasicnetworkctionwithifupdown@}@ .

The ifplugd

The ifplugd package starts interfaces upon interfaces are connected to the network instead of upon device discovery by the interface. Thus, this can be used to avoid problem described in @{@thetroublednetwonnectionrecovery@}@ .

Here is how to use the ifplugd package for the internal Ethernet port, e.g. eth0:

  • Remove stanza in /e/n/i: "auto eth0" and "allow-hotplug eth0"

  • Keep stanza in /e/n/i: "iface eth0 inet dhcp"

  • Install the ifplugd package

  • Run "sudo dpkg-reconfigure ifplugd" and put eth0 as the "static interfaces to be watched by ifplugd".

(!) The use of the ifplugd package enables us to avoid the slow DHCP timeout delay when the Ethernet wire is disconnected.

The waproamd

(!) Need to be tested by me! Just by summarizing manual:

The waproamd package works like ifplugd for the wireless LAN by configuring WEP keys before AP associations succeed.

The mapping with guessnet

(!) Need to be tested by me! TBD

Instead of manually chosing configuration as described in @{@themanuallyswitcorkconfiguration@}@, you can use the "mapping" mechanism and the guessnet-ifupdown(8) command with slightly modified e/n/i:

auto lo
iface lo inet loopback

mapping eth0
 script guessnet-ifupdown
 config1 config1 pppoe
 map default: dhcp
 map timeout: 3
 map verbose: true

iface config1 inet dhcp

iface config2 inet static
 address 192.168.11.100
 netmask 255.255.255.0
 broadcast 192.168.11.255
 gateway 192.168.11.1
 dns-domain lan
 dns-nameservers 192.168.11.1

iface pppoe inet ppp
 provider dsl-provider

With above "mapping" stanza with guessnet-ifupdown(8), the execution of:

$ sudo ifup eth0

will produce the execution of:

$ sudo ifup eth0=$(echo -e 'default: dhcp \n timeout: 3 \n verbose: true' | guessnet-ifupdown eth0)

to configure eth0 automatically.

The output of the guessnet-ifupdown command is determined by the test condition for each network configuration directly taken from the test sub-stanza of iface stanza in e/n/i and output the name of the first non-ERROR result. (The network configuration name is the immediate string after the iface stanza and alternatively called as the logical interface name.)

(!) The following is a place holder. Copied from the Debian package:

The example /e/n/i file in /usr/share/doc/guessnet/examples gives good idea how it works:

auto lo
allow-hotplug eth0

iface lo inet loopback

mapping eth0
 script guessnet-ifupdown
 # List of stanzas guessnet should scan for
 #   If none is specified, scans for all stanzas
 #map home work
 map default: dhcp
 map timeout: 3
 map verbose: true

# Home network configuration
iface home inet static
 address 192.168.1.2
 netmask 255.255.255.0
 broadcast 192.168.1.255
 gateway 192.168.1.1
 dns-search home.lan
 dns-nameservers 192.168.1.1
 # Check for one of these hosts:
 test1-peer address 192.168.1.1 mac 00:01:02:03:04:05
 test2-peer address 192.168.1.3 mac 00:01:02:03:04:06

# Work network configuration
iface work inet static
 address 10.1.1.42
 netmask 255.255.255.0
 broadcast 10.1.1.255
 gateway 10.1.1.1
 dns-search work.lan
 dns-nameservers 10.1.1.1
 # the other guessnet scan:
 test-command /usr/local/bin/check_work

# Second job network configuration
iface work2 inet static
 address 192.168.2.23
 netmask 255.255.255.0
 broadcast 192.168.2.255
 gateway 192.168.2.1
 dns-search work2.lan
 dns-nameservers 192.168.2.1
 # Specify a source address in case the peer doesn't reply to
 # ARP packets coming from 0.0.0.0
 test-peer address 192.168.2.1 mac 00:01:02:03:04:05 source 192.168.2.23

# PPPOE network configuration
iface pppoe inet ppp
 test pppoe
 # It could also be:
 #test-pppoe please

# I'd really appreciate a 'disabled' method for iface (#275326)
iface interface inet manual
 test missing-cable
 pre-up echo No link present.
 pre-up false

# guessnet default
iface none inet dhcp

Now when plug your Ethernet connector, the hotplug event will bring up eth0 with the proper configuration through the mapping offered by the guessnet system.

(If you drop the "allow-hotplug eth0" stanza in the above example, you can manually bring up eth0 with the proper configuration through the mapping offered by the guessnet system just by issuing "ifup eth0".)

The network connection test

The basic network test

The network-test command from the ifupdown-extra package provides the easy network connection test.

$ network-test 
INFO: This system has exactly one default route
INFO: Host localhost answers to ICMP pings
INFO: Loopback interface is working properly
INFO: The lo interface is up
INFO: The lo interface has IP address 127.0.0.1 assigned
INFO: The lo interface has tx and rx packets.
INFO: The eth1 interface is up
INFO: The eth1 interface has IP address 192.168.11.2 assigned
INFO: The eth1 interface has tx and rx packets.
INFO: The router 192.168.11.1 is reachable
INFO: This system is configured to use nameserver 192.168.11.1
INFO: Host 192.168.11.1 answers to ICMP pings
INFO: Dns server 192.168.11.1 resolved correctly www.debian.org
INFO: The nameserver configured for this system works properly
INFO: System can reach Internet host www.debian.org
INFO: System can access web server at Internet host www.debian.org

This ifupdown-extra package also installs a set of scripts in /etc/network/*/ to enhance ifupdown package. These scripts can:

  • check the network cable before an interface is configured. (/etc/network/if-pre-up.d/00check-network-cable)

  • test if an assigned IP address is already in use in the network. (/etc/network/if-up.d/10check-duplicate-ip)

  • setup default static routes for interfaces. (/etc/network/if-up.d/20static-routes)

  • test if default network gateways are reachable. (/etc/network/if-up.d/30check-gateway)

The compatible lower level network operations

You may use the lower level network commands as follows anytime since they do not change network configuration:

List of lower level network commands.

command

effects

"ifconfig" without arguments

displays the status of active interfaces (IPv4)

"route -n"

display all the routing table in numerical addresses (IPv4)

"ip link show"

displays the link status of active interfaces (IPv4/v6)

"ip addr show"

displays the link and address status of active interfaces (IPv4/v6)

"ip route show"

displays the routing table (IPv4/v6)

"plog"

display ppp daemon log

"ping yahoo.com"

check Internet connection to yahoo.com

"traceroute yahoo.com"

trace Internet connection to yahoo.com

"dig [@dns-server.com] example.com [{a|mx|any}]"

check example.com DNS records by dns-server.com for a {a|mx|any} record

"iptables -L -n"

check packet filter

"netstat -a"

find all open ports

"netstat -l --inet"

find listening ports

"netstat -ln --tcp"

find listening TCP ports (numeric)

"cat /etc/network/run/ifstat"

list currently active interfaces managed by the ifupdown package

"dlint example.com"

check dns zone information of examle.org

{i} Some of these lower level network configuration tools reside in /sbin/. You may need to issue full command path such as /sbin/ifconfig or add /sbin to the PATH list in your ~/.basrc.

The screen program

The screen program (popcon: @@@pop-screen@@@) enables remote shell process to survive the interrupted connection. This is the essential tool for people to access remote sites via the unreliable connection.

The use scenario for the screen command

Here is a typical use scenario of the screen program.

  1. You log in to a remote machine.
  2. You execute the "screen" command on a single console.

  3. You execute multiple programs in the screen windows created with ^A c ("Control-A" followed by "c").

  4. You switch among the multiple screen windows by ^A n ("Control-A" followed by "n").

  5. Suddenly you need to leave your terminal, but you don't want to lose your active work by keeping the connection.
  6. You detach the screen session by any methods such as:

    • brutally unplugging your network connection,
    • typing ^A d ("Control-A" followed by "d") and manually logging out from the remote connection, or

    • typing ^A DD ("Control-A" followed by "DD") to have screen detach and log you out.

  7. You log in again to the same remote machine (even from a different terminal).
  8. You enter the "screen -r" command.

  9. The screen program will magically reattach all the previous screen windows with all the actively running programs.

This is good way to save connection fee if you are on the dial-up network connection.

The key bindings for the screen command

In screen session, all keyboard inputs are sent to your current window except for the command keystroke, by default ^A ("Control-A"). All screen commands are entered by typing ^A plus a single key [plus any parameters]. Here are important ones to remember:

List of key bindings for screen.

key binding

meaning

^A ?

show a help screen (display key bindings)

^A c

create a new window and switch to it

^A n

go to next window

^A p

go to previous window

^A 0

go to window number 0

^A 1

go to window number 1

^A w

show a list of windows

^A a

send a Ctrl-A to current window as keyboard input

^A h

write a hardcopy of current window to file

^A H

begin/end logging current window to file

^A ^X

lock the terminal (password protected)

^A d

detach screen session from the terminal

^A DD

detach screen session and log out

See screen(1) for details.

The screen like program for the X

Install the xmove package to enable support for mobile X11 clients. See xmove(1).