|
![]() |
|
198 days, 8 hours, 7 minutes until the end of the Bush presidency. |
Linux Home NetworkingAuthor: Michael Minn (see michaelminn.com for contact info) December 31, 2007 An overview of hardware and techniques for networking Linux computers in a home or small business environment 1. IntroductionFrom it's origins, the UNIX operating system has been oriented around networking and UNIX machines are generally very easy to network and use on networks. Networking is a huge topic, but the following contains some basic information that should be helpful for configuring modest home and small business networks. Basic information is also provided for connecting your Linux box to a network associated with a larger institution (such as a university). Although a number of graphical user interfaces are available for network configuration, use of software that shields the user from the technical workings of their system can sometimes be counterproductive. In a Linux environment where hardware and drivers are not specifically designed for the plethora of configurations, understanding the details of how a system is configured can be extremely helpful for diagnosing problems and actually save time. With that premise in mind, all configuration in this document is performed by editing system files or using command line programs. This document is not intended to be complete and I welcome any suggestions for it's improvement. 2. HardwarePerhaps the biggest issue facing a Linux user is finding hardware that is supported by vendor or open source drivers. Many manufacturers guard information about their hardware as trade secrets and see no need to expend effort on developing drivers for a rather small group of Linux users. Research: However, there are numerous vendors and projects that fill some of the holes. It is therefore ESSENTIAL that before purchasing hardware that you check the hardware compatibility lists AND Google your hardware to verify that drivers are available. The following are some online resources, although they are usually behind the curve and search engines will find up-to-date information.
Hardware Versions: Hardware vendors often change chipsetss while keeping the same model number. This means that two cards with the same model number can actually be completely different hardware, and Linux drivers for the old model may not work for the new version. Linux drivers often trail introduction of a product by months, by which time the vendor may have moved on to yet another chip vendor. Thankfully, many vendors issue the new hardware with a different "version" number that can be used to distinguish different releases of the same hardware. Product or serial numbers can also be used to distinguish new versions. BUYER BEWARE. Some information for specific hardware (current at the time of this writing) are given later in this document. Network Card: Every device on the network needs a network interface of some kind. Most new desktop and laptop computers have ethernet ports (RJ-45 connectors) and modem ports (RJ-11 or phone line connectors), although the chips driving them may not have Linux drivers. Wireless and wired cards are available as internal cards (for desktops) or PCMCIA or USB devices. Again, do your research before buying. Switches/Routers: Once you have machines with network cards, you need some way to connect them. For a small number of machines, consumer-quality switches are usually simpler than routers. Routers are more complex and usually associated with a shared internet connection. Switches and routers often are mixed. There is a central router connected to the internet. Multiple machines in one room can be connected to a switch, which then has a single wire connected to the central router. Crossover Cables: If you are only connecting two machines, perhaps to share files between a laptop and a desktop, all you need is a crossover cable to connect them. Although this cable appears identical to a regular ethernet cable, the connectors are wired so the outputs of one machine go to the inputs of the other. Access Points: For wireless networks, you need one or more access point to serve as a router between machines and between the network and an internet connection. It is possible for wireless machines to connect directly to each other (ad-hoc mode), although most networks centralize control (and internet access) through access points. Modems: Modems are used to connect to a remote machine (such as your internet service provider) through a phone line (dial-up or DSL) or cable connection. 3. A Two Computer NetworkI frequently need to share files between my laptop and desktop. One easy way to do that is to network the two together as a simple wired peer-to-peer network. This also serves as a simple example for Linux system configuration. Crossover Cable: For hardware, each computer needs an ethernet card (10/100BaseT) and an RJ-45 CROSSOVER cable. Note that this is a crossover cable and not just a regular CAT-5 patch cable. Unless you're using a hub, the wires have to be "crossed over" to directly connect two PCs. Device NamesAn internal, PCMCIA or USB networking device that has appropriate supporting modules installed on a machine will be recognized at boot or by hotplugging when the device plugged into the machine. Ethernet devices recieve the name ethX, where X is a number assigned by the sequence in which the device is detected. The first device is eth0, second device eth1, etc. IP Addresses: Unless you have a DHCP server or want to set one up, you will need to choose static IP addresses. I use the Class C addresses 192.168.1.1 and 192.168.1.2 on my two machines, respectively. Configuration File: A configuration file is needed for each device. Configuration files are located in /etc/sysconfig/network or /etc/sysconfig/network-scripts and named ifcfg-XXXX, where XXXX is the name of the device. For example, my /etc/sysconfig/network/ifcfg-eth0 file for an internal card on a network with statically assigned IP addresses: DEVICE=eth0 STARTMODE=onboot BOOTPROTO=static IPADDR=192.168.1.1 NETMASK=255.255.255.0 Accordingly, the /etc/sysconfig/network-scripts/ifcfg-eth1 file for a second PCMCIA card: DEVICE=eth1 NAME=eth1 STARTMODE=hotplug BOOTPROTO=static IPADDR=192.168.1.2 NETMASK=255.255.255.0 Start The Interface: To start and stop the interface, there are two scripts: ifup and ifdown. /sbin/ifup eth0 /etc/fstab: To tell the Linux file system how to mount the network, edit the /etc/fstab file and add the following line on the 192.168.1.2 machine, pointing to the 192.168.1.1 machine. On the 192.168.1.1 machine, the address would be changed to point to the 192.168.1.2 machine. The options in fourth column indicate not to try to mount at boot time (noauto), to allow a regular user (not just superuser) to mount the drive (user) and to timeout rather than retrying indefinitely if there is a problem accessing the device (soft). The given mount point (/mnt/network) can be any directory you prefer. If there is a confusion about protocols with the serve, and explicit version option may also be necessary (i.e. nfsvers=2) 192.168.1.1:/home /mnt/network nfs noauto,user,exec,soft 0 0 Firewall Configuration: NFS uses TCP/IP port 2049. The default firewalls on many distributions will cause mounting a drive on a remote machine to fail with the message "RPC: Port mapper failure - RPC: Unable to receive". If the firewall is left on the receiving machine, the mount will delay and finally issue the message "RPC: Timed out" Firewall - SuSE: SuSE provides a utility that handles the otherwise difficult configuration of iptables. For a simple home network with no serious security risk, you can just specify which device is your internal device and turn off protection from the internal network. You SHOULD NOT do this if your internal network is used to share an internet connection. The SuSE configuration file is /etc/sysconfig/SuSEfirewall2. Modify the following entries FW_DEV_INT="eth0" FW_PROTECT_FROM_INTERNAL="no" # this is the key Firewall - iptables: Non-SuSE machines require direct configuration of iptables. On both machines, add a new iptables rule that accepts all input on the eth0 interface from both 192.168.1.1 and 192.168.1.2. List the new table and if everything looks good, save it to the /etc/sysconfig/iptables file. /sbin/iptables -I INPUT -p ALL -s 127.0.0.1 -j ACCEPT /sbin/iptables -I INPUT -p ALL -i eth0 -s 192.168.1.1 -j ACCEPT /sbin/iptables -I INPUT -p ALL -i eth0 -s 192.168.1.2 -j ACCEPT /sbin/iptables -L /sbin/iptables-save > /etc/sysconfig/iptables Firewall - ipchains: Some machines use ipchains, a separate but similar firewall service. There are syntactical differences in configuration since the two programs handle forwarded packets differently. /sbin/ipchains -I input -p ALL -i eth0 -s 192.168.1.1 -j ACCEPT /sbin/ipchains-save > /etc/sysconfig/ipchains Test the Connection: If the system is configured properly, you should be able to ping one system from the other. You can also ping yourself. If you're on 192.168.1.1: ping 192.168.1.2 Should give something like this: PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data. 64 bytes from 192.168.1.2: icmp_seq=0 ttl=64 time=0.895 ms 64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=0.435 ms 64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=0.430 ms A machine can also ping itself to verify that it's own interface is working. 4. NFSTo provide mutual access to files between both machines, you will need to set both machines up as Network File System file servers and clients. NFS Exports: The /etc/exports file tells NFS which directories to make visible to network systems. To make the /home directory visible to both machines with the IP addresses given above, the /etc/exports file on both machines would have one line: /home 192.168.1.1(rw) 192.168.1.2(rw) Export these file systems after modifying /etc/exports. The file systems will subsequently be exported each time the system is rebooted. /usr/sbin/exportfs -a -v Configure NFS to Start On Boot: This will cause the NFS daemons to be started at boot time. Since this opens potential vulnerability to hackers, you should not do this if you do not plan to use NFS regularly. /sbin/chkconfig nfs on /sbin/chkconfig nfslock on NFS Configurations: Start the NFS daemons /etc/init.d/nfs start /etc/init.d/nfslock start /etc/init.d/portmap restart Mount: Network file systems just like physical drives: mount /mnt/network Network file systems can also be mounted explicitly (without an entry in the /etc/fstab file: mount 192.168.1.1:/home /mnt/network Debugging - Server Is Down: The error message "mount to NFS server 'x.x.x.x' failed: server is down" may, in fact, mean that the server is not running or that you do not have connectivity to the server (see below for ping). It can also be caused if the server does not have an entry in /etc/exports giving you permission to mount the requested resource (see above). However, this message may also be caused by a NFS protocol version mismatch. The Linux NFS client supposedly supports NFS protocol versions 2, 3, and 4 but the server doesn't seem quite so robust. Use the nfsvers=2 option on the mount command (or in /etc/fstab) to force use of NFSv2. mount -o nfsvers=2 192.168.1.1:/home /mnt/network Much love to Sergejs Svitnevs for pointing this out on an HP IT Resource Center Forum. Debugging - NFS Server Not Up: Error message "RPC: Program not registered" or "RPC: Unable to receive; errno = Connection refused" on the client machine may mean the NFS server not started /etc/init.d/nfs start Debugging - Connectivity: If you are still having problems, you should try pinging the other machine to make sure it can be reached. Failure on the ping indicates a IP connection problem. ping 192.168.1.1 Debugging - Ports: NFS uses TCP port 2049. rpcinfo can be used to list available ports. Problems with rpcinfo indicates a machine is not accepting NFS requests. /usr/sbin/rpcinfo -p 192.168.1.1 /usr/sbin/rpcinfo -p 192.168.1.2 You can also verify open ports with netstat. nfs should be listed for both tcp and udp, although only the tcp port will be in LISTEN state # netstat -tul Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:nfs *:* LISTEN tcp 0 0 *:printer *:* LISTEN tcp 0 0 *:676 *:* LISTEN tcp 0 0 *:sunrpc *:* LISTEN tcp 0 0 *:x11 *:* LISTEN tcp 0 0 *:ha-cluster *:* LISTEN tcp 0 0 *:32893 *:* LISTEN tcp 0 0 *:32894 *:* LISTEN udp 0 0 *:nfs *:* udp 0 0 *:32782 *:* udp 0 0 *:32783 *:* udp 0 0 *:673 *:* udp 0 0 *:691 *:* udp 0 0 *:bootpc *:* udp 0 0 *:727 *:* udp 0 0 *:sunrpc *:* Debugging - iptables Firewall: If all else fails, you can simply stop the firewall. It can be restarted by replacing stop with restart. /etc/init.d/iptables stop FYI, the important line in /etc/sysconfig/iptables is the rejection of port 2049, used by NFS: -A RH-Lokkit-0-50-INPUT -p udp -m udp --dport 2049 -j REJECT Debugging - SuSE Firewall /etc/init.d/SuSEfirewall2_setup stop 10. SambaThe Windoze operating system shares files through Server Message Blocks (SMB) and Network Message Blocks (NMB). Directories on a Windoze system that are made available for network access are called Shares. Samba is an open source package that provides file access between Windoze and Linux machines using SMB/NMB. Samba configuration is a huge topic, but some basic configuration information is given here for a simple home network. The utilities provided with Samba permit both access of Windoze shares from Linux systems and sharing of Linux directories with Windoze systems. 10.1 Sharing Linux Files with Windoze Systemsuseradd: Samba users from Windoze should have user accounts on the Linux machine. Usernames are added with the useradd command and passwords are set/changed with passwd. All users should have directories in /home as well. useradd (username) passwd (username) mkdir /home/(username) This can be combined into a single useradd request useradd -m -d /home/(username) -p (password) (username) smbpasswd: Samba keeps usernames and passwords in a separate file from regular Linux passwords. The smbpasswd command is uaed to add/delete Samba users. smbpasswd -a (username) /etc/samba/smb.conf: security: The type of access available for ALL samba shares are defined in the [global] section of /etc/samba/smb.conf. "share" security is read only, "user" security is read-write. [global] # read only access security = share # security = user /etc/samba/smb.conf: shares: Samba "shares" are configured in /etc/samba/smb.conf. To configure a share named (sharename), add the following section to the file
[(sharename)]
comment = Shared directory named (sharename)
path = (filepath)
valid users = (username)
read only = No
Starting Samba Services: The rcnmb and rcsmb scripts start Samba filesharing and naming services: rcnmb start rcsmb start Firewall Mounting Samba Shares: Samba shares on other Linux or Windoze systems can be mounted just like other file systems and /etc/fstab can be used to define mount points and options. Example line in /etc/fstab: //(server)/(sharename) /(mountpoint) smb noauto,user,soft,ip=192.168.1.1,username=(user) 0 0 testparm: lists Samba shares and verifies correct syntax of configuration files smbstatus: a simple program to list currently open Samba connections. 10.2 Accessing Windoze Shares from LinuxIt is possible to access shares on a Windoze system from a Linux box either through smbclient (a program similar to FTP) or by mounting the shares as an SMB filesystem on Linux. The following examples presume unprotected shares. You may need additional workgroup/username/password information if the share is protected. Find the IP address of the server: You should be able to get the IP address of the computer hosting the shares by simply viewing the network properties of the host. However, if you are in an unfamiliar environment, you can use NMAP to find valid IP addresses on a network. If the network is set up with DHCP, you can get the IP info for the network with ifconfig. Assuming a 192.168.0.0 network with a mask of 255.255.255.0 nmap -sP 192.168.0.0/24 List services on the computer: You can get the network name of the host computer by listing available services with nmblookup. Assuming the host computer IP is 192.168.0.1: nmblookup -A 192.168.0.1 List shares on a computer: Assuming that you found the 192.168.0.1 computer is named "mainserver", you can list the available shares with smbclient. Note that server names are normally preceded with "\\", but because the UNIX shell uses the slash as a special character, you use \\ to represent \\ UNLESS you put quotes around the whole name. smbclient -L \\\\mainserver -I 192.168.0.1 Connect to a share: If you only need to do simple transfer of files from/to the share, you can use the smbclient as a simple FTP-like program. Assuming a share named "sharedirectory" on computer "mainserver": smbclient "\\mainserver\sharedirectory" "" -I 192.168.0.1 smbmount mounts a share so it can be accessed through the Linux filesystem. The findsmb and smbtree commands are available for viewing networks, although they requre additional configuration to work properly 11. DHCPDHCP (Dynamic Host Configuration Protocol) is a service provided by a server for assigning IP addresses to network hosts dynamically and eliminating the need to manually assign IP addresses to each computer on a network. The DHCP server needs a static IP address, but all hosts can have their network interface configurations set to get an IP address from the DHCP server. 11.1 DHCP ClientMost non-trivial networks, including networks that have access points or use routers to connect to the internet, have DHCP servers of some kind. A network card will get an address when the interface is brought up. Therefore dhcp must be specified in the config file for the particular interface. For a simple network card on eth0, the /etc/sysconfig/network-scripts/ifcfg-eth0 file will be: DEVICE=eth0 NAME=eth0 BOOTPROTO=dhcp ONBOOT=yes You can verify successful assignment of a dynamic IP address with ifconfig. You can also see diagnostic messages issued when seeking a DHCP address at the end of /var/log/messages DHCP addresses are "leased" for a set duration. There may be situations (such as DHCP server testing) where you need to relinquish a DHCP lease and acquire a new IP address. This can be done with dhclient. To release an IP address /sbin/dhclient -r To acquire a lease for one new IP address: /sbin/dhclient -1 11.2 DHCP Server/etc/sysconfig/dhcpd: Setup for a simple network is quite easy. Add an entry to /etc/syconfig/dhcpd for the network interface that will be be connected to hosts: DHCPD_INTERFACE="eth0" /etc/sysconfig/dhcpd.conf: Add a range of addresses that can be allocated to /etc/dhcpd.conf
ddns-update-style none;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.3 192.168.1.3;
}
iptables: Configure the firewall config file to permit incoming DHCP requests. (FYI: DHCP utilizes UDP on ports 67 and 68) /sbin/iptables -I INPUT -p ALL -i wlan0 -s 192.168.2.3 -j ACCEPT /sbin/iptables-save > /etc/sysconfig/iptables SuSE Firewall: If you're using SuSe, modify the following line in the /etc/sysconfig/SuSEfirewall2 file: FW_SERVICE_DHCPD="yes" Lease Info: Information about current DHCP leases is listed in /var/lib/dhcp/dhcpd.leases 12. Dialup AccessAlthough dialup access to the internet is rapidly going the way of buggy whips, millions of people still connect to the internet via analog phone lines. And travelers who stay in cheap hotels often find it necessary to get a dialup connection. Internal Modems: Finding a modem that works with Linux is actually a bit harder than it would seem. Most laptop and external modem designers have chosen to simplify their designs by moving some of the analog signal processing out of hardware and into the driver software. Since these drivers are almost never written for Linux, this presents a severe problem. However, there are a relatively small number of manufacturers making the chips used in these WinModems and, thankfully, SOME manufacturers and private developers have developed Linux drivers. Some resources for finding Linmodem info:
To know which driver to use, you need to know what chip the modem uses. This can be especially difficult on laptops or external devices where it is not easy to pop the case open and see the hardware. For internal modems, if you have Windoze installed, you can get the Properties of your LAN connection for detailed info. Lacking Windoze info, you may also be able to use the /sbin/lspci -vv command, although this may not be of value since dial-up modems are often hidden behind AC'97 chips, such as this listing from my Toshiba 1905 laptop: 00:1f.6 Modem: Intel Corp. 82801BA/BAM AC'97 Modem (rev 05) (prog-if 00 [Generic]) Subsystem: Toshiba America Info Systems: Unknown device 0001 Control: I/O+ Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- Status: Cap- 66Mhz- UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR-Destination Gateway Genmask Flags Metric Ref Use Iface nas31.newyork1. * 255.255.255.255 UH 0 0 0 ppp0 default nas31.newyork1. 0.0.0.0 UG 0 0 0 ppp0 whois queries the Internet WhoIs database to find out who a domain name is registered to. Anonymous or third-world registrations often indicate entities that you should have no dealings with. whois can also be used to list to what organization an IP address has been assigned to, although this information will often only lead you to an ISP that controls a block of IP addresses and not to the company or individual who is actually using that IP address. airsnort: When you need to connect to an encrypted network but do not have the encryption key, AirSnort can listen to traffic for a period of time and determine the key. nmap is a network exporation tool and security scanner. Lots of options. The -sT option is especially useful for detecting "open ports" that represent potential entry paths for invaders and the results of this scan may indicate unnecessary services you want to shut down or unnecessary permissions in your firewall. Example: scan a local address for open ports nmap -sT 192.168.1.1 Example: looks for hosts on a network nmap -sP 172.16.1.1-127 Netdisco is an open source web-based network management tool. It's quite complex and I mention it here only as a suggestion if you're looking for network discovery software. nmblookup, smbstatus and findsmb are utilities for diagnosing and establishing Samba connections to Windoze systems. They are described earlier in this document. |
|
I am 216.14.213.113.
You are 38.103.63.17 |
A lawn is not a thing, it is a relationship. All content on this site (c) 2000-2008 by Michael Minn or the respective copyright owners. |