500 likes | 679 Views
INFO 320 Server Technology I. Week 6 Networking. Overview. Now we’ll focus on basic networking concepts for servers, and see how they’re implemented in Ubuntu Networking overview Interface configuration Other networking files Networking programs. Networking overview. Why network?.
E N D
INFO 320Server Technology I Week 6 Networking INFO 320 week 6
Overview Now we’ll focus on basic networking concepts for servers, and see how they’re implemented in Ubuntu Networking overview Interface configuration Other networking files Networking programs INFO 320 week 6
Networking overview INFO 320 week 6
Why network? Why do we need a network? Networking is a big problem To solve it, make little problems out of it That’s why networking is broken into layers, each of which has a designated job The message an app wants to send is broken into packets and sent across the network INFO 320 week 6
Networking layers Each layer Has a specific job to do Has protocols associated with it Looks at a certain kind of address See networking summary under INFO 330 INFO 320 week 6
Networking layers The layers of networking spell out ‘All Turtles Need Less Protection’ * Application Transport Network Link Physical * I apologize for this dreadful mnemonic – let me know if you think of a better one! INFO 320 week 6
Networking protocols TCP and UDP are the transport layer protocols TCP provides polite reliable delivery, UDP is fast and dumb IP (Internet Protocol, v4 or v6) defines the host addresses Other network layer protocols define how packets are routed to get to their destination INFO 320 week 6
Addresses As noted, there are three kinds of networking addresses The transport layer uses the port numberof the receiving process The network layer uses the IP address of the receiving host (computer) Usually this is the only one we care about The link layer uses the MAC address of the receiving adapter (e.g. Ethernet interface) INFO 320 week 6
Addresses Notice that IP and MAC addresses belong to interfaces; each network interface has a fixed MAC address, and is assigned an IP address Older computers typically only had one interface (e.g. Ethernet) and therefore one IP and one MAC address Now your computer or router might have both wired and wireless interfaces INFO 320 week 6
Domain and host names Read names backward The last part is the Top Level Domain (TLD) (edu, com, gov, uk, etc.) The next to last part with the TLD makes the domain name (drexel.edu) The full address of the computer is the host name (www.drexel.edu, www.webmail.google.com) INFO 320 week 6
Networking and client/server Most protocols use the client/server model A client process asks a server process for information The server process usually provides it Notice this is a different kind of “client/ server” from the hardware architecture Any computer can have client and/or server processes running on it INFO 320 week 6
Networking apps Key Internet apps include DNS, ARP, DHCP, and NAT DNS (Domain Name Service) converts hostnames (www.drexel.edu) to IP addresses; also looks up email servers A Berkeley Internet Name Domain (BIND) server implements DNS INFO 320 week 6
Networking apps A BIND server is also called a nameserver or DNS server The command nslookup finds DNS information for a domain name nslookup ubuntu.com ARP (Address Resolution Protocol) translates MAC addresses to IP addresses INFO 320 week 6
Networking apps DHCP (Dynamic Host Configuration Protocol) automatically assigns IP addresses to computers within a network If you don’t use this, you have to assign IP addresses manually for each interface NAT (Network Address Translation) allows a network to use local IP addresses that aren’t visible to the outside world INFO 320 week 6
Interface configuration INFO 320 week 6
Borrowing from Debian Ubuntu borrows from its Debian heritage in terms of network configuration The primary network configuration file is/etc/network/interfaces It contains network configuration information for all devices on the system The script /etc/init.d/networking reads /etc/network/interfaces INFO 320 week 6
/etc/network/interfaces The details of this file are messy – see man 5 interfaces It contains network interface configuration information for the ifup(8) and ifdown(8) commands Within this file, comments must start at the beginning of the line with a # The file consists of zero or more "iface", "mapping", "auto" and "allow-" stanzas INFO 320 week 6
Loopback interface First let’s allow us to talk to ourselves – the loopback interface When we want to talk to our own system across the network, the loopback interface prevents us from actually leaving the computer It’s given a reserved IP address (?) INFO 320 week 6
Loopback interface The loopback is automatically configured, typically with these ‘stanzas’ in the interface file auto lo iface lo inet loopback INFO 320 week 6
Loopback interface Notice everything’s lower case lo = name of loopback interface ‘auto’ has it brought up automatically on boot The ‘iface’ stanza defines the interface and creates its settings, here to be a loopback ‘Stanzas defining logical interfaces start with a line consisting of the word "iface" followed by the name of the logical interface’ (from the man page) INFO 320 week 6
inet? Normal TCP/IPv4 networking uses ‘inet’ as the protocol type If you’re using IPv6, use ‘inet6’ instead Other options exist, such as ‘ipx’ for Novell NetWare If this were 1995, that last reference would make sense to you INFO 320 week 6
Ethernet interfaces Ok, let’s try something more interesting How about an Ethernet interface? Ethernet interfaces are typically given names starting with ‘eth’, e.g. eth0, eth1 If we’re configuring it with DHCP our life is easy auto eth0 iface eth0 inet dhcp INFO 320 week 6
Static Ethernet interfaces In contrast, if we want to set up our interfaces manually, we make them static (as in static routing) iface eth0 inet static address 10.1.1.10 netmask 255.255.255.0 gateway 10.1.1.1 INFO 320 week 6
Gateway address The gateway address is a key concept It identifies the device you need to contact to get to the rest of the world It’s also called your first-hop router INFO 320 week 6
allow- stanzas ‘Lines beginning with "allow-" are used to identify interfaces that should be brought up automatically by various subsytems’ allow-hotplug eth1 Goes with ifup --allow=hotplug eth0 eth1 Which will only bring up eth0 or eth1 if it is listed in an "allow-hotplug" line INFO 320 week 6
Mapping ‘Stanzas beginning with the word "mapping" are used to determine how a logical interface name is chosen for a physical interface that is to be brought up’ Mapping defines scripts that decide how an interface is to be configured INFO 320 week 6
Mapping example mapping eth0 script /usr/local/sbin/map-scheme map HOME eth0-home map WORK eth0-work iface eth0-home inet static address 192.168.1.1 netmask 255.255.255.0 iface eth0-work inet dhcp INFO 320 week 6
ifup and ifdown? ifup - bring a network interface up ifdown - take a network interface down These commands do just that – take interfaces up (running) or down ifup eth0=home Means ‘Bring up interface eth0 as logical interface home’ Can use on the command line too INFO 320 week 6
ifup and ifdown? Other examples are simpler; bring up eth0 with ifup eth0 Or shut down all interfaces with ifdown -a How could this command be used to produce a DoS attack? INFO 320 week 6
Wireless networking There are wireless options that can be included in the interface config file See the wireless man page for gory details For example, they can specify the SSID and type of networking mode wireless-<function> <value> wireless-essid Home wireless-mode Ad-Hoc INFO 320 week 6
Restart to apply changes If you change /etc/network/interfaces, restart networking to make the changes active sudo /etc/init.d/networking restart INFO 320 week 6
Other networking files INFO 320 week 6
Other networking files A few more files are important to networking, including /etc/resolv.conf /etc/hosts /etc/services /etc/protocols INFO 320 week 6
/etc/resolv.conf This text file is the place where your DNS servers are identified When you get an account with an ISP, you get two DNS server IP addresses This file lists them nameserver 10.1.1.2 nameserver 10.1.1.3 DHCP will set this file for you INFO 320 week 6
/etc/resolv.conf Here you can also specify the local domain name domain drexel.edu This is appended when you try to go to a local server ‘myserver’ it fills out the full host name myserver.drexel.edu INFO 320 week 6
/etc/hosts This file was used to list all the hosts on the Internet (!) IP_address hostname [aliases...] DNS made that purpose obsolete (yay!!!) Now it just defines localhost and loopback addresses, but it precedes DNS Your system will consult this file before DNS! (See /etc/host.conf to prove it) INFO 320 week 6
/etc/hosts Most systems have a small host table containing the name and address information for important hosts on the local network This is useful when DNS is not running, for example during system bootup INFO 320 week 6
/etc/hosts example 127.0.0.1 localhost 192.168.1.10 foo.mydomain.org foo 192.168.1.13 bar.mydomain.org bar 146.82.138.7 master.debian.org master 209.237.226.90 www.opensource.org Notice that three of these lines include aliases INFO 320 week 6
/etc/services /etc/services lists the network services available on your system (e.g. HTTP, FTP, Telnet, etc.), and the port numbers they use In contrast, /etc/protocols lists the TCP/IP protocols supported by your system, and gives a description of each INFO 320 week 6
Networking programs INFO 320 week 6
Networking programs We’ll look at a few networking applications dmesg ifconfig netstat route ping, finger , who , host , traceroute wireshark, tcpdump, EtherApe, nagios3 INFO 320 week 6
dmesg A lesser known command is dmesg The program helps users to print out their bootup messages A handy diagnostic tool in case something breaks during boot So what does this do? dmesg > boot.messages INFO 320 week 6
ifconfig ifconfig can be used to configure network interfaces, but is being replaced by ifup and ifdown By itself as a command, it gives the status and data about all interfaces or a specific interface ifconfig ifconfig eth0 INFO 320 week 6
ifconfig It can set the IP address of an interface ifconfig eth0 123.45.67.89 Or bring up an interface ifconfig eth0 up It’s vaguely similar to the Windows command ipconfig (notice the spelling difference!) INFO 320 week 6
netstat netstat is a very powerful command, with zillions of options to get network status for interfaces, protocols, routes, groups, etc. For example, netstat –rn gives the routing table (-r) with numeric output of IP addresses (-n) The actual routing table is in the file /proc/net/route INFO 320 week 6
route The route command gives the routing table, or can add or delete entries from it For a given range of IP addresses, a routing table tells which interface a packet needs to use to get there So the first and last columns are most important here – for a given ‘Destination’, I should ‘Use Iface’ eth0, for example INFO 320 week 6
Routing table For example, ifconfig and route can be used to define a new Ethernet card, and add it to the routing table ifconfig eth1 192.168.1.3 route add 192.168.1.3 dev eth1 INFO 320 week 6
Other networking apps ping tells you if a host is connected to the network finger tells what users are online who and w tell what users are on the local network host gives info about a domain traceroute gives the path to a host INFO 320 week 6
Packet capture apps Many tools exist to capture packets on the network, and analyze them including wireshark tcpdump EtherApe netstat and nagios3 do network monitoring as well INFO 320 week 6
References Most of the hyperlinks in this set of notes are to the corresponding man pages for Ubuntu 9.04 Networking Summary, dated October 21, 2009 Glenn Booker The rest of the information is mostly from (Rankin, 2009) and (Petersen,2009) INFO 320 week 6