Pin Me

Linux Networking - Principles of Network Configuration

written by: •edited by: Eric Stallsworth•updated: 6/22/2011

Setting up your networking configuration is a primary task on every OS, and Linux is no exception. Those that are able to communicate through the Internet have a clear advantage over those that don't.

  • slide 1 of 5

    Introduction

    Nowadays being able to communicate through the Internet is crucial for any working environment. People depend on the ability to share and have instant access to information to do their daily job.

    Linux, being the result of a concerted effort of programmers around the world, had its networking capabilities incorporated in early stages of development. UUCP was present on Linux from almost the beginning, with the net-1 added later on and constantly rewritten and improved until the latest net-4 code which is present in the kernels we use today.

  • slide 2 of 5

    Serial Hardware

    Like all devices in a Unix system, serial ports are accessed through device special files located in the /dev directory. These device special files are named ttyS0, ttyS1, etc. where COM1: is represented by /dev/ttyS0, COM2: by /dev/ttyS1 and so on (remember counting in unix starts from 0).You can find your list of serial devices as shown below:

    ls -l /dev/ttyS*

    crw-rw---- 1 root dialout 4, 64 Nov 15 11:13 /dev/ttyS0

    crw-rw---- 1 root dialout 4, 65 Nov 15 11:13 /dev/ttyS1

    crw-rw---- 1 root dialout 4, 66 Nov 15 11:13 /dev/ttyS2

    crw-rw---- 1 root dialout 4, 67 Nov 15 11:13 /dev/ttyS3

    setserial was created to configure the serial driver at runtime. Its general syntax is:

    setserial device [parameters]

    Some of the most common parameters of the setserial command are:

    port_num the I/O port address of the serial device

    irq num the interrupt request line

    auto_irq automatically determine the irq

    skip_test skip the UART test during auto-configuration

    An example setserial command would be:

    /sbin/setserial /dev/ttyS0 auto_irq skip_test autoconfig

    You can find more information about setserial in the man page.

    An alternative to the setserial command is stty which is most commonly used to configure terminal parameters. Since serial devices are tty devices, the stty command is equally applicable to them.The stty command provides a bewildering number of characteristics that you can configure, but the depth of that discussion is outside the scope of this article.

  • slide 3 of 5

    Ethernet

    Ethernet devices are the common standard for TCP/IP communications today. In Linux, the very first interface to be activated is usually the loop back interface (identified by lo). Other interfaces such as the LAN interface for local networks and the WLAN interface for wireless connections are commonly identified by eth0 and wlan0 ( this can vary in different distributions).

    To make an interface accessible to the kernel network layer the command ifconfig is used. It enables the assignment of ip addresses and other parameters, as well as activation of the interface (also known as “bringing it up”). The simplest way to invoke ifconfig is with:

    ifconfig interface ip-address

    This command assigns ip-address to interface and activates it. All other parameters are set to default values. We can use ifconfig to get a list of devices of our system by simply typing ifconfig without any additional parameters.

    The command to activate eth0 and configure a class C ip address would be:

    ifconfig eth0 192.168.0.113 netmask 255.255.255.0

    route allows you to add or remove routes from the kernel routing table. It can be invoked as:

    route [add|del] [-net|-host] target [if]

    The most common use for route is to add a default gateway to the routing table, but it can of course be used to add complex routes to the system routing table.

    Simply enough, all you need to do is use ifconfig and route to configure your ip address and default gateway (as shown in the example below) and your Linux is ready to go online:

    ifconfig eth0 192.168.0.113 netmask 255.255.255.0

    route add default gw 192.168.0.1

    For more informations on the ifconfig and route commands you can check out the respective man pages.

  • slide 4 of 5
    Linux Wireless Networking Principles: Easy steps to connect Linux to a Wireless Hotspot.Internet connection via cable is almost history. Everywhere you go (a library, the airport or simply a coffee shop), Internet connectivity is provided via Wireless access points. This page will show you how to instantly connect to the Wireless connection and have a cable-free life.
  • slide 5 of 5

    Wireless Networking

    Different manufacturers use a slightly different architecture to provide 802.11b functionality. There are two major chipset manufacturers (Hermes and Prism), and internally hardware manufacturers have made modifications to increase security or speed. While initially Hermes cards were predominant due to the popularity of Lucent WaveLAN (Orinoco) cards, a majority of card makers today use Prism's prism2 chipset. Some well-known Prism cards are those from D-Link, Linksys, and USR.

    802.11b networks can be configured to operate in several different modes. The two main types you're likely to encounter are infrastructure mode (sometimes referred to as managed mode) and ad-hoc. Infrastructure mode is the most common and uses a hub-and-spoke architecture in which multiple clients connect to a central access point.

    In order to be able to configure your wireless networking devices, you will need the Linux Wireless Extension Tools. These tools are very useful for configuring every aspect of your wireless networking devices such as if you want to easily set up ad-hoc networks or change the default wireless options. iwconfig is the primary configuration tool for wireless networking which will allow you to change all aspects of your configuration, such as the ESSID, channel, frequency, and WEP/WAP keying. iwconfig is similar to ipconfig, but it has some additional wireless specific options such as:

    essid set the essid of the wireless network

    ap set the mac address of the access point to connect to

    mode set the operating mode(ad-hoc,managed,repeater etc)

    key set the current encryption key

    The general syntax is essentially the same as ifconfig:

    iwconfig interface ip-address

    For example, to connect to the foo wireless network which has a mac address of 00:11:22:33:44:55 and a subnet of 10.0.0.0 you would use this series of commands:

    iwconfig wlan0 essid foo

    iwconfig wlan0 ap 00:11:22:33:44:55

    ifconfig wlan0 10.0.0.113/24

    route add default gw 10.0.0.1