------------------------- Week 07 Notes for NET2003 ------------------------- -Ian! D. Allen - idallen@idallen.ca - www.idallen.com Remember - knowing how to find out an answer is more important than memorizing the answer. Learn to fish! RTFM! (Read The Fine Manual) Keep up on your readings (Course Outline: average 5 hours/week homework). A good way to memorize the material is to take notes in class and then merge your notes with my published note summaries after class. You won't be able to Google search during tests and exams. * Abbreviation "ALN" = your "Advanced Linux Networking" text by R.W.Smith ---------------------------------------------------------------------------- News this week: http://www.news.com/8301-10784_3-9878655-7.html?tag=nl.e498 - more specific network route hijacks YouTube traffic to Pakistan ---------------------------------------------------------------------------- Review: - you understand that commands can be substituted like variables - you know how $PATH works, and how to tell which commands will execute - you know the basic shell order of expansion - you can list processes, yours and others - you can create a symbolic link to a file or directory - you can use basic shell control structures if/then/else/while - you know these tests: -z -n -r -w -x -s -e -L -f -d -a -o - you can create or expand a tar archive ---------------------------------------------------------------------------- System Logging - file /etc/syslog.conf and directory /var/log/ -------------- System logging is configured via /etc/syslog.conf and managed by SysV start-up scripts such as klogd and sysklogd. The main daemon name is usually "syslogd" with a Kernel daemon "klogd": $ ps laxww | grep syslogd $ ps laxww | grep klogd Logs are usually stored under directory /var/log/; but, /etc/syslog.conf may have syslog put them anywhere. Unix/Linux System logging - figuring out where things go wrong: - logging needs a system log daemon and kernel log daemon running: - daemon is started via a script: /etc/init.d/syslog or /etc/init.d/sysklogd - syslog config file: /etc/syslog.conf - the config file assigns types of logging to various file names - usual syslog log file directory: /var/log/* - know how to find out where the logs are kept! Kernel messages: - "dmesg" shows the kernel ring buffer (limited size) - works without any log daemons running Q: What file controls and configures system logging? Q: Under what directory are most log files usually stored? Q: What command shows the kernel ring buffer, even if logging isn't enabled? ---------------------------------------------------------------------------- Debian package tools -------------------- # apt-get update # apt-get install pkgname # dpkg -l (see dpkg-query) # dpkg -L pkgname (see dpkg-query) # dpkg-query -W pkgname # dpkg-query -l pkgname # dpkg-query -p pkgname # dpkg-query -L pkgname # dpkg-query -S filename # apt-cache search package_pattern # apt-file search file_pattern Q: What command fetches and installs a package on a Debian system? Q: What command searches for package names in a (cached) list? Q: What command searches for file names in a (cached) list? ---------------------------------------------------------------------------- VMware network reconfiguration: NAT vs. bridged -------------------------------------------------- Alternative network config for those using wireless or VPN or who have only a single IP address at home: - in your VMplayer click on the Ethernet device and change the type of network on eth0 from "bridged" to "NAT" (or try "host-only") - start your VNS - make sure pump is running on eth0 (should be there already) - "ifconfig eth0" should show a private address - "ip route" should show a route to your VNS host machine gateway private IP - should be able to ping this gateway private IP - see if you can ping your VNS host machine external address - see if you can ping something on the Internet - details: see http://cri.ch/linux/docs/sk0020.html - you can also directly edit your *.vmx file and add/change this line: - ethernet0.connectionType = "nat", "hostonly" or "bridged" See Notes file: vmware_networking.txt ---------------------------------------------------------------------------- Choosing a File System Type --------------------------- Your system install created "journalling" file systems on your virtual disk, using the "-t ext3" option to mkfs. Another way to request this kind of file system is to use the "-j" (Journalling) option to the original "mke2fs" command. This type of Linux journalling file system is usually called "ext3", and some distributions have a small shell script named "mke3fs" that simply calls mke2fs with the "-t ext3" or "-j" option. Journalling file systems are more resistant to corruption due to sudden power loss, allowing the system to come back up more quickly by avoiding a long file system check at boot time. (This does *NOT* give you permission to power off a running Linux system! Always shut down cleanly.) Q: What is the advantage of a journalling file system? ---------------------------------------------------------------------------- Network Diagnostic Tools ------------------------ Please re-read the "Acceptable Use Warning" on the course home page. Note that at Algonquin College many/most network probe ports and protocols (even ping and sometimes traceroute) are blocked and will *NOT* work. Sorry! Try them at home instead. These tools are helpful in diagnosing network problems: arp - show/change MAC addresses currently known to this host ethereal - GUI packet sniffer fuser - (-n tcp, -n udp) list processes with open TCP or UDP ports mtr - ping-style traceroute: packet route diagnostic netcat (nc) - Network Swiss Army Knife: connect/listen to ports netstat -natu - list open and listening TCP and UDP connections nmap - Network Mapper - port prober ping - ICMP echo generator/receiver tcpdump - command-line (non-GUI) packet sniffer telnet - TCP connection program: use when netcat is not available traceroute - packet route diagnostic Scanning for hosts on a net: # nmap -sP 192.168.9.0/24 Starting Nmap 4.20 ( http://insecure.org ) at 2008-02-14 21:19 EST Host 192.168.9.182 appears to be up. MAC Address: 00:0C:29:8F:E6:38 (VMware) Host 192.168.9.183 appears to be up. MAC Address: 00:19:5B:8C:90:B7 (D-Link) Host 192.168.9.250 appears to be up. Host 192.168.9.254 appears to be up. MAC Address: 00:04:E2:A7:EB:A8 (SMC Networks) Nmap finished: 256 IP addresses (4 hosts up) scanned in 5.477 seconds Major service port numbers (often seen in trace output): - port numbers are given names in the file /etc/services - see also the master list at http://www.iana.org/assignments/port-numbers TCP 20 ftp-data TCP 21 ftp (control) TCP 22 SSH TCP 23 telnet TCP 25 SMTP (sending mail only) UDP/TCP 53 domain (DNS) UDP 67-68 DHCP TCP 80 HTTP (WWW) TCP 110 POP3 (receiving mail only) TCP 113 ident (identifying incoming TCP connections) TCP 119 NNTP (Network News) UDP/TCP 123 NTP (Network Time) UDP/TCP 137-139 Microsoft netbios (SMB) (Samba) TCP 443 HTTPS (secure WWW) UDP/TCP 445 Microsoft-DS UDP/TCP 631 Internet Printing Protocol (IPP - CUPS) Individual network servers/daemons (e.g. ssh, http) may start up individually through individual start-up scripts, or they may run on demand out of the master "inetd" or "xinetd" super-servers (ALN p.89,96). A server must be configured to start individually or to start via xinetd - having both enabled will cause a port conflict. Do it one way or the other. Q: T/F A network server may be configured to start via xinetd and via an init.d script at the same time. ---------------------------------------------------------------------------- Linux Boot, init, and Start-Up Run Levels ----------------------------------------- At power on or reset, the BIOS finds and executes the boot block from the first available disk/cdrom/floppy/usb drive. The boot block redirects to a bootloader program such as LILO or GRUB. LILO/GRUB allow a choice of kernels to boot. - the Linux loaders will load almost anything (including Windows) - GRUB: see /boot/grub/menu.lst - LILO: see /etc/lilo.conf - loader can pass options to the kernel using a "kernel command line" - a copy is available as /proc/cmdline when the system is running - services can look in this command line for keywords/values - e.g. the word "single" boots Linux in single-user maintenance mode - see /etc/event.d/rc-default The kernels boot within a small "mini-root" environment that has only a limited set of commands and modules available. This environment is stored in a compressed "initrd" file and is part of the boot process. You need to preconfigure this file with the basic necessary drivers your system needs to get started, using "mkinitrd" or "mkinitramfs". Once the kernel gets going in the "miniroot" environment, it switches to using the main disk and can use the full set of kernel modules. The Linux kernel runs Process #1 named "init": - all subsequent processes fork/exec and are descendants of this one - processes without parents (orphans) are inherited by init The init process is responsible for starting up the system, including all the system services ("daemons"), windowing, and login shells. There are two modern ways for init do do this: 1. Starting services on non-Ubuntu, or Ubuntu pre-2007: - the system has seven different "run levels" (only about 4 used) - init runs the "rc" scripts corresponding to the default run level - the "rc" scripts start up daemons and perform system services - the initdefault run level setting is in /etc/inittab - use "telinit" to change run levels - use "runlevel" to display the run levels - /etc/rc?.d/* or /etc/rc.d/rc?.d/* are symlinks to /etc/init.d/* 2. Starting Services on Ubuntu 2007+: - new "upstart" facility: http://www.linux.com/feature/125977 - init reads the /etc/event.d directory for jobs to managed - no more "run levels" - they are emulated and will be phased out - telinit, runlevel, /etc/rc?.d compatibility provided - initctl controls jobs ("events") - you can create an /etc/inittab if needed to set a boot run level The problem with the older run-level technology is that it doesn't cope well with hardware changes. The new "upstart" system is intended to handle changing hardware conditions (hotplug) after the machine has booted. These are some services that might be enabled at boot time: - dhcp client - dhcp server (be careful where you run this - you can hijack a network!) - ssh server - ntp - smtp server (Postfix) - fetchmail - http (Apache) - smb (Samba) Q: What is the name of the System V start-up directory for run level 1? Q: What is the name of the job/event directory for the "upstart" init system? Q: Why is upstart better than Systev V run levels? ---------------------------------------------------------------------------- Linux server initialization and start up: ALN Chapter 4 ------------------------------------------------------- * Readings in ALN Chapter 4 - Starting Servers: ALN Chapter 4 - "Starting Servers" p.79-89 Read: Using SysV startup scripts Read: Using inetd Skip: the /etc/inetd.conf file format Read: using TCP wrappers Read: Using xinetd Read: Using local startup scripts Skip: Using GUI tools Read: When to use each startup method Read: Summary Most Unix/Linux distributions provide a SysV RC "network" start-up script - may be called /etc/init.d/network or networking - script may detect and load special modules (e.g. ipv6) - script may set network kernel options using sysctl - see /etc/sysctl.conf - may use helper scripts such as "ifup" and "ifdown" to start network - Debian: see info in master network config file /etc/network/interfaces - Debian: each network device has a stanza in the one "interfaces" file - may start network interface monitoring programs such as ifplugd - see the config file under /etc/ifplugd/ - enabling the network device also adds a route for that device, and possibly a gateway for that network start-up script symlinks in /etc/rc?.d/ or /etc/rc.d/rc?.d/ start "daemons" - many daemon programs listen on well-known TCP and UDP network ports - /etc/services is a plain text list of names of many well-known ports - see also the master list at http://www.iana.org/assignments/port-numbers For systems using traditional System-V start-up, the /etc/inittab file lists the run levels defined on your system. Not all levels are always used. The keyword "initdefault" in /etc/inittab is associated with the default run level for your system. The run levels are not "sequential". Going to run level 3 does not mean going through levels 0,1,2 first. Think of the numbers as just names for the levels. When you change levels, some services will be shut down and others will be started, depending on what is running in the old level and what needs to run in the new level. Unix now has three major ways to start servers as the system is booting. Originally (Berkeley Unix) servers were started by editing a large "rc.sysinit" file. System V Unix introduced a directory of individual "rc" start-up files; most Unix systems use this System V "rc" method. Ubuntu introduced the "Upstart" package that uses "events" and an /etc/event.d/ directory; though, the events still currently simulate the old run-level system. System-V style server start-up scripts (early Ubuntu, RedHat, others): See course text ALN Chapter 4 "Starting Servers" p.79-89 - chkconfig and ntsysv are not present under Debian/Ubuntu/Knoppix - chkconfig is available on Mandriva/RedHat but not Debian/Ubuntu/Knoppix - some systems have ksysv (X11 graphical only) Master run level directory: /etc/init.d/ or /etc/rc.d/init.d/ - this dir contains scripts that will start/stop each service, given the appropriate command line argument of "start" or "stop" - init.d is a directory of *possible* services; not all of them may be in use; see the /etc/rc?.d/ directories for current use Run level directories: /etc/rc?.d/ or /etc/rc.d/rc?.d/ - contain symbolic links to scripts in /etc/init.d - numbers in the link names determine order of script execution - script names starting with K will be called with "stop" when moving to that run level, e.g. "/etc/init.d/httpd stop" - script names starting with S will be called with "start" when moving to that run level, e.g. "/etc/init.d/httpd start" - the scripts look at the first argument and do the appropriate thing Debian networking is started/stopped using the SysV script "networking". At boot time, this start-up script calls "ifup -a" to bring up all interfaces configured as "auto" in /etc/network/interfaces. The main "networking" SysV script is linked symbolically into the run level directories rc?.d. You can also call the script manually: # /etc/init.d/networking stop # /etc/init.d/networking start The Debian network start-up script will only configure interfaces listed as "auto" in /etc/network/interfaces - if that file is empty, nothing happens; or, if you run Network Manager, the Network Manager will try to configure your unmanaged interfaces for you. You can use the Network Manager icon on your desktop to turn off "roaming" and set an interface to "manual configuration", at which point entries are made in the interfaces file and the "ifup" and "ifdown" commands will work. Using the main network start/stop script will affect all your configured network interfaces, including the "loopback" interface, and configure your default gateway. Using the "ifup" and "ifdown" scripts affects only one interface and may not set your default gateway. Use the main network script unless you are doing something unusual. Q: What is the name of the Debian network start-up script? Q: What is the principal network config file for Debian systems? Q: What config file is used by the Debian "ifup" and "ifdown" commands? Q: Where are the links to start-up scripts for run level 3 kept? Q: What does the "auto" keyword mean in the Debian "interfaces" file? Q: What file stores the addresses of the DNS servers used by this machine? Q: What file lists and sets the run levels? Q: In what directory are the master System V run-level scripts stored? Q: What do the prefixes S and K mean in the symlink directory for a run level? ---------------------------------------------------------------------------- Configuring Hardware and Drivers -------------------------------- Reference: ALN p.31-33 Loading Network Drivers Basic network connectivity, from the hardware in - how much autoconfig will your distribution do? - Knoppix does massive autoconfig at boot time; many servers do none Most Linux distributions contain auto-configuration programs that detect your network card during installation and create the necessary start-up code to load the correct network drivers for you. - Ubuntu has hardware probing at installation time - Knoppix has an excellent (if slow) hardware probing start-up script - auto-config is typically not done for servers - server hardware doesn't change daily; autoprobing would slow down a reboot and possibly make unauthorized changes to configuration files - auto-config must locate drivers for newly discovered hardware - some boot-time hardware detection scripts: kudzu, harddrake, etc. - without auto-config, you have to know what drivers match which hardware - changing hardware means changing config files - drivers load into the running kernel using "insmod", usually called from an easier-to-use wrapper routine named "modprobe" - use command "lsmod" to see drivers currently loaded into the kernel: $ lsmod | grep scsi - use "rmmod" to remove a loaded kernel module (if it isn't busy) - Note: most drivers can be compiled into the base kernel instead of loaded as modules at run time; lsmod will not show these compiled-in drivers! Q: What is the easiest command to use to load a module into the kernel? Q: What command shows modules that have been loaded? Q: T/F The lsmod command shows all modeules, even ones that have been compiled into the kernel. You can see your network hardware using these commands for PCI and USB: $ lspci $ lsusb Both have "-v" verbose options. Q: What two commands show hardware devices on your PCI and USB buses? In Linux, Ethernet card network interfaces are given names such as "eth0" and "eth1" at boot time. Modern systems have a "udev" capability that attaches these names to specific network cards without the need for config files. Older systems have alias names set down in /etc/modules.conf or, for older-newer 2.6 kernels, /etc/modprobe.conf (ALN p.32), or, for Debian systems, directory /etc/modprobe.d/. The alias names connect the abstract names "eth0", "eth1", etc. with the actual Ethernet driver module names, e.g. "eth0 tulip", "eth1 3c95x". Debian systems sometimes have an /etc/iftab file that connects card names with MAC addresses. See iftab(5) ("man 5 iftab"): eth0 mac 00:0e:a6:c3:a0:78 arp 1 eth1 mac 00:0e:a6:c3:96:1e arp 1 The network names may be managed by MAC address by udev: # grep -r eth0 /etc/udev /etc/udev/rules.d/70-persistent-net.rules:SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:0c:29:8f:e6:38", NAME="eth0" Linux network driver modules are kept in /lib/modules/*/kernel/drivers/net/ and you can insert these drivers into your kernel (so that it recognizes a particular Ethernet card) using "modprobe" and just the module name, e.g.: # modprobe 3c59x # ALN p.32 says "insmod"; use modprobe To display loaded kernel modules (including drivers for Ethernet cards): # lsmod To see the latest kernel status messages related to loading a module or driver, use the "dmesg" command, and also check the system log files under /var/log/ (usually files "messages" or "syslog" are important here). Once the correct modules are loaded, you can display the known network interfaces using netstat or ifconfig with the "-a" option: # ifconfig -a # all possible interfaces # netstat -ai # all possible interfaces # ifconfig # only active (up) interfaces # netstat -i # only active (up) interfaces Kernel Interface table Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-DRP TX-OVR Flg eth0 1500 0 41880706 0 0 0 59937708 0 0 BMRU eth1 1500 0 96932 0 0 0 9 0 0 BMRU eth2 1500 0 9462750 1 0 0 12525371 0 0 BMRU lo 16436 0 12111590 0 0 0 12111590 0 0 LRU ppp0 1452 0 128366 0 0 0 181827 0 0 MOPRU Q: What command(s) display all possible network interfaces? Many proprietary hardware drivers cannot be distributed with the Linux kernel; you may have to search the manufacturer web site to find them and download them, and you have to match the driver to the specific Linux kernel you are running. You can find out your kernel name using: $ uname -a Linux elm 2.6.20-16-generic #2 SMP Tue Feb 12 05:41:34 UTC 2008 i686 GNU/Linux Q: What is the purpose of the two-digit number that follws S or K in the symlink names in the run-level start-up directories? p.82 Q; How can you arrange that a start-up script is always started when the system enters, say, run level 3? p.83 Q; How can you temporarily (until the next boot) start or stop a server? p.83 Q: How can you set the run level in preparation for the next reboot? p. 87 Q: T/F Run levels 2-5 have standard meanings across all Linux distributions. p.87-88 Q: What command changes the current run level in a running system? p.88 Q: T/F System start-up scripts are standard across all linux distributions. p.100-101 ---------------------------------------------------------------------------- Getting a machine on the net - network parameter requirements ------------------------------------------------------------- At minimum, your machine needs two network parameters to be a good network citizen: 1. an IP address assigned to at least one connected network card 2. a network mask or prefix length, so you the machine knows which IP addresses are on the local net and which are not Q: What are the two minimum network parameters needed to allow your machine to talk on the local network? If you want to talk to more than your local network, you also need: 3. the IP address of a gateway machine (for off-net access) Q: What are the three minimum network parameters needed to allow your machine to talk to machines that are not on your local network? If you want to use names instead of IP addresses, you need: 4. addresses of DNS server(s) to resolve host names 5. a host name for your machine (fully qualified with a domain name) You can program your machine with all or some these things directly (static addressing); or, you can have your machine broadcast a request to see if some other machine on the network has its configuration info: DHCP, BOOTP(old), RARP The Unix "hostname" command shows and sets the machine host name. ALN p.48 Q: What command sets or shows your system host name? The Unix "ifconfig" command shows and sets IP addresses and network masks on interfaces. ALN p.36 Q: What command sets and shows your network interface parameters? A "gateway" machine is a machine on your local network to which packets will be sent if your machine doesn't know where else to send them. Without a gateway, your machine can only communicate with other machines on the local network segment (the local ARP domain). The "route" and "ip route" commands can set and display network route tables that use gateway IP addresses, including the "default" route to your gateway machine(s). ALN p.40-42 Q: What command(s) set and show your kernel network routing tables? The "arp" command shows the kernel table listing current known MAC addresses on the local network. Q: What command shows the currently known MAC addresses? You can run your machine without defining any DNS servers, in which case you will have to use IP addresses (not names) for all hosts. If you want to use DNS names, The file /etc/resolv.conf ("man resolv.conf") contains the definitions of your domain name and your DNS servers. ALN p.47 A network broadcast address can be calculated from IP and mask. Q: What Internet network access is possible without a DNS server? Q: What Internet network access is possible without a gateway machine? Q: What Internet network access is possible without a network mask? Q: I want my computer to talk to another computer on the same network as mine. What minimum network configuration do I need? Q: I want my computer to talk to another computer on a different network from mine. What minimum network configuration do I need? Q: What file stores the addresses of the DNS servers used by this machine? Network configuration - DHCP or static -------------------------------------- If your computer has simple network connectivity, you never need to use any of the low-level Linux network or routing commands. Either DHCP configures your system for you; or, you set up static routing using system configuration files (which differ between RedHat and Debian systems). With reference to the above network parameter requirements: DHCP often supplies the host name for your machine. Whether or not DHCP is used depends on how the distribution is configured at boot. Often, the act of bringing up an interface will also bring up the DHCP client for that interface, if the config file says to do so. *** Debian-style systems 1. Debian systems keep network information in /etc/network/interfaces ("man 5 interfaces"). All the interfaces are configured in one single file. The "dhcp" keyword indicates using DHCP. The "ifup" and "ifdown" commands use this file. (ALN p.34 bottom) 2. Debian program defaults are usually kept under /etc/default/ Q: What is the principal network config file for Debian systems? Q: What config file is used by the Debian "ifup" and "ifdown" commands? Q: What Debian network keyword, used in the interfaces file, indicates that an interface uses DHCP? A. Configuring DHCP networking (client) ALN Chapter 2 p.33-36 ------------------------------------------------------------- For the DHCP client to work, your system must have some DHCP client software package installed. Some common DHCP package names are "pump" and "dhclient". There are many, many packages that relate to DHCP: $ apt-cache search DHCP | wc 58 424 3045 Q: What is the name of one DHCP client? A DHCP-configured machine usually receives all the required network parameters (hostname and domain, IP address, Gateway address, and DNS server info) via the DHCP protocol. Q: What basic network information is supplied to a client by a DHCP server? All Unix/Linux machines keep DNS resolver information in "/etc/resolv.conf". The /etc/resolv.conf file is set up automatically (overwritten!) when your client gets its IP address via DHCP. Q: What file gets overwritten when a DHCP server supplies your system with the IP addresses of DNS servers? You can use the following commands to query the state of your machine (host name, IP address(es), gateway address [default route], and DNS information): # hostname foo.happy.machine.ca # ifconfig eth0 eth0 Link encap:Ethernet HWaddr 01:A0:CC:2C:A8:00 inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0 [...] # route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 * 255.255.255.0 U 0 0 0 eth0 default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 # ip route 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.2 default via 192.168.1.1 dev eth0 # cat /etc/resolv.conf search happy.machine.ca domain happy.machine.ca nameserver 192.168.1.3 nameserver 192.168.1.4 Q: What commands let you determine these basic network settings: machine name, interface addresses, routing tables, DNS servers ? You can use the above commands to display the current host name, network, route, and DNS information. Given a properly configured DHCP server, there is no need to manually use "hostname", "ifconfig" or "route" to configure your network address or routing tables - the networking start-up script (run via symbolic links in the /etc/rc?.d directories) should examine your network config file, discover that you want DHCP, and do all the netowrk configuration for you. Debian network start-up script: /etc/init.d/networking Q: What is the name of the system start-up script for networking on a Debian system? Q: What is the principal network config file for Debian systems? Q: What file stores the addresses of the DNS servers used by this machine? Q: How does a DHCP client locate a DHCP server? p.33 - T/F: Linux has only two common DHCP client packages. p.33 Q: What is the name of the DHCP client for Debian systems? p.35 (table) Note on p.35 the misuse of the term "start-up script" for Debian DHCP; in fact, client DHCP doesn't have a traditional System V init.d start-up script. Client DHCP is started/enabled for an interface if the network configuration asks for it; so, client DHCP is started as part of bringing up the network. It doesn't make sense to "start DHCP" if you haven't specified which network interface on which to listen. The Debian network start-up script name is "/etc/init.d/networking", and inside that start-up script is a call to the binary program "ifup -a" that uses the Debian master network config file /etc/network/interfaces, and in that master config file the keyword "dhcp" on an interface signals the use of a DHCP client, e.g. iface eth0 inet dhcp Q: What is the absolute pathname of the Debian System V network start-up script? Q: Give the absolute pathnames of the file you must edit to configure a client static or DHCP network interface under Debian/Ubuntu/Knoppix. B. Configuring static networking - ALN p.36-49 ---------------------------------------------- If you use static addresses instead of DHCP for one or more of your network interfaces, you must set some or all of the required network configuration parameters yourself (host name, IP address(es), gateway machine, DNS servers). You may not have to set all of the parameters if your host has multiple interfaces and some other interface already sets some of the required network parameters (e.g. you may already have a DNS server configured). If you use only static IP addressing (no DHCP), you must manually set your host name and domain, IP address, network mask, gateway IP (default route), and DHCP servers. Without DHCP, some systems set your hostname at boot time using an init.d script. Often the script gets the information from a text file named /etc/hostname or /etc/HOSTNAME. DNS domain and name server info are kept in file /etc/resolv.conf. ("man resolv.conf") For a static network, you must edit this file. On Debian (Ubuntu, Knoppix, etc.) all the network interface parameters are set in one big file /etc/network/interfaces ("man 5 interfaces"): - One network config file for all interfaces: /etc/network/interfaces - "ifup" and "ifdown" use this file (empty file, no networking!) - the Debian network start-up script /etc/init.d/networking uses this file by calling the "ifup -a" command (no file, no networking!) - Sample /etc/network/interfaces file: # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface, auto-started at boot auto lo iface lo inet loopback # The primary network interface, auto-started at boot auto eth0 iface eth0 inet static address 192.168.1.1 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.254 # This is all you need for a dhcp interface, auto-started at boot auto eth1 iface eth1 inet dhcp Q: What is the format of the Debian master network config file? If you have special routing needs, you will need to understand Linux routing and add special routing commands to the networking config files. Note that most desktop systems, including those running Network Manager, may have issues with making more than one network connection work at the same time. Q: How would you configure a Debian system eth0 for DHCP at boot time? Q: What is the principal network config file for Debian systems? - What command shows the IP addresses on each network interface? (ALN p.36) - True/False: giving a single interface name argument to the ifconfig command toggles the interface (if the interface is up, it takes it down; if down, it brings it up) p.37 - True/False: if you don't supply a netmask to the ifconfig command when you bring up an interface, the netmask is set based on the traditional TCP/IP class (A,B,C) of the address. p.37 - What is the traditional/default netmask for IP address 10.34.56.78? p.39 - What are the two functions of the Linux routing table? p.40 - How does Linux find out the IP addresses of hosts on a directly-connected network? p.40 - What is the purpose of a "gateway" IP address? p.40 - What command configures the Linux routing table? p.41 (Modern Linux systems use "ip route".) - True/False: Linux systems only allow one gateway address. p.41 - In which order does the kernel match an outgoing packet destination address against the table of routes? p.41 - What is another common name for the most general route in the routing table (the route that matches any address)? p.41 - How does using the ifconfig command affect the routing table? p.42 - True/False: using the route command without any parameters, or with just the "-n" parameter, clears the current routing table. p.42 - What command shows the default gateway? (ALN p.40-42) - What is the most common use of the "route" command? p.44 - True/False: the ifconfig command also adds a route to your gateway when you bring up an interface. p.44 - What are the two types of actions needed to manually configure a machine with multiple interfaces and one gateway? p.44 - By default, Linux does not route packets between different interfaces. How do you enable routing (forwarding) between interfaces? p.44 - True/False: It is safe and normal for a router to run non-routing software (e.g. a GUI, web server, ssh, telnet, etc.). p.44 - What command shows the list of DNS servers? (ALN p.46-47) - True/False: once you have put DNS servers in the /etc/resolv.conf file, you must start/stop the network using the /etc/init.d/network script to make the changes active. p.48 - What command sets/shows the global host name of a Linux machine? (ALN p.48) - True/False: a Linux computer with multiple network interfaces will normally have a main host name and also separate names for each network interface. p.49 - True/False: Using the "hostname", "ifconfig" and "route" commands makes permanent changes to your system that will re-appear on reboot. p.49 - True/False: a static network configuration doesn't need a Gateway machine or default route.