[ Contents ]
[ Prev ]
[ Next ]
Lucky With LAN
- Working with a LAN (Local Area Network) requires installing a LAN card
in your computer.
- Usually, the LAN you are connecting to is of type 'Ethernet', and requires
an Ethernet controller (or Ethernet NIC - Network Interface Card).
- After installing and configuring the Ethernet controller, we need to set
up a means for our machine to be identified on the network.
- On some networks, each machine is given a static address. On other
networks, addresses are set dynamically, as the machine boots.
- Finally, we might want to mess a bit with routing information. This
is usually not required on end-user machines, though.
Ethernet Cards - Not Your Friendly "Egged" Drivers
- For each Ethernet controller - there is an Ethernet driver that is
required to control it. This driver is part of the kernel. Usually - a
separate module (configured using the '/etc/conf.modules' or
'/etc/modules.conf' file, depending on your kernel versions and module
utils (modutils) versions).
- A common problem with Using Ethernet drivers is detection problems during
installation, that lead to the system loading the wrong driver module.
- Note: with today's Linux distributions, PCI plug & play Ethernet
controllers are often detected and configured automatically by the
system installation process, with no problems.
- If you have an older Ethernet card, you might need to configure its
IRQ and I/O address manually, using jumpers or dip-switches on the
controller itself. After that, you should tell your system the exact type
of Ethernet controller you have, and if you are lucky, the kernel will
detect the IRQ and I/O address on its own.
- The Ethernet HOWTO contains more details on setting up Ethernet
controllers.
Networks And Net-masks
- Each computer connected to the Internet (or any TCP/IP network) is
identified by an address, called "IP address".
- IP addresses are written as a set of numbers (also called "octets"),
separated by dots. For example: 192.217.24.5
- IP addresses belong to networks, or sub-networks. IP addresses assigned
to machines on the same LAN should belong to the same sub-network.
- In order to specify the sub-network an IP address belongs to, we use
a net-mask. It looks something like: 255.255.255.0
- The net-mask defines which part of the IP address represents the network
address, and which part represents the host address.
- In our example above, the network address would be 192.217.24.0
- Conclusions: all machines connected to the same LAN, should have the same
netmask, and IP addresses that begin with the same prefix.
IP Configuration Of The Ethernet Controller
In order to actually configure the Ethernet controller's IP address (assuming
a static IP here), one may use the 'ifconfig' command (as user root, of-course).
Here is how:
[root@simey ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:01:02:9D:EB:92
inet addr:192.217.24.5 Bcast:192.217.24.255 Mask:255.255.255.0
UP BROADCAST RUNNING MTU:1500 Metric:1
RX packets:2256 errors:0 dropped:0 overruns:0 frame:0
TX packets:2868 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
Interrupt:12 Base address:0xec00
We see here the internet address of the card, the broadcast address for its LAN,
the netmask, and a few other parameters. To actually set these parameters, the
command used could have been:
ifconfig eth0 192.217.24.5 netmask 255.255.255.0 broadcast 192.217.24.255
Note: running the 'ifconfig' command in read-only mode may be done by any user,
not just root, using the command's full path - '/sbin/ifconfig'.
The Route To Freedom
- When we configure a network device, the system automatically sets up
routing to the network this device connects to, to handle all IP addresses
that belong to the sub-net this device is configured for.
- In human speak, this means that if we set up an Ethernet controller with
an IP address of 192.217.24.5 and a netmask of 255.255.255.0, then our
machine automatically knows that communicating with machines whose IP
address begins with '192.217.24.' should be done on the LAN, directly
via our Ethernet controller.
- In order to allow our system to communicate with machines that are not
part of our LAN, we need to set up more routing information.
- Normally, an end-user machine only needs to know that communications
to non-local machines should go through a gateway machine. This gateway
machine is connected both to our LAN, and to other networks, and routes
communication data between our LAN and those other networks.
- This setup is known as "default gateway". This means, we tell our system
that communications with any machine not found on our LAN should be done
via this gateway.
Viewing The Routing Table
In order to view our system's routing table (the table defining how to
communicate with various systems), we may use the 'netstat -r' command:
[choo@simey ~]$ netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.217.24.5 * 255.255.255.255 UH 0 0 0 eth0
192.217.24.0 * 255.255.255.0 U 0 0 0 eth0
127.0.0.0 * 255.0.0.0 U 0 0 0 lo
default 192.217.24.254 0.0.0.0 UG 0 0 0 eth0
As we can see, data sent to the address '192.217.24.5' should go through the
Ethernet controller. Data sent to our LAN (network 192.217.24.0) also goes
through the Ethernet controller. Data sent to network '127.0.0.0' - a special
machine internal network, goes via a special loopback device, which is
a virtual device. Finally, data sent to any other IP address is sent to the
gateway machine '192.217.24.254', via our Ethernet controller.
Automatic Configuration using DHCP
- As mentioned above, on some networks, IP addresses (and net-masks) are
assigned dynamically to machines.
- This assignment is often done using DHCP (Dynamic Host Control
Protocol). In this protocol, a machine that boots up, sends a broadcast
message on its LAN, asking for its IP address. A DHCP server reads this
request, and sends a reply, containing the machine's IP address, netmask
and default gateway.
- On Linux, we can use the 'pump' command in order to become a DHCP client.
All we need to do is launch the 'pump' command (either during the system
startup process, or at the prompt of user 'root'), and it will handle
the DHCP process. For more information - man pump. One can also
use the 'dhcpcd' (note the 'cd', for client) daemon to get a DHCP
address. for more more information, man 'dhcpcd'.
[ Contents ]
[ Prev ]
[ Next ]