Linux Routers and Community Networks
Total Page:16
File Type:pdf, Size:1020Kb
Summer Course at Mekelle Institute of Technology. July, 2015. Linux Routers and Community Networks Llorenç Cerdà-Alabern http://personals.ac.upc.edu/llorenc [email protected] Universitat Politènica de Catalunya, Barcelona, Spain Revision: 0e36644 (2015-07-09) Llorenç Cerdà-Alabern Linux Routers and Community Networks 1 / 191 Summer Course at Mekelle Institute of Technology. Linux Routers and Community Networks Introduction Where I come from Linux Routers Parts I Introduction II Lab 1: Basic Network Configuration III Lab 2: RIP and OSPF IV Lab 3: Firewall configuration V Lab 4: Community Networks VI Lab 5: Network Management Llorenç Cerdà-Alabern Linux Routers and Community Networks 2 / 191 Summer Course at Mekelle Institute of Technology. Linux Routers and Community Networks Introduction Where I come from Part I Linux Routers Introduction Outline Where I come from Linux Routers Llorenç Cerdà-Alabern Linux Routers and Community Networks 3 / 191 Introduction Where I come from Introduction Mekelle vs. Barcelona Where I come from Linux Routers • Barcelona - Mekelle: 7,660 km Ethiopia Spain Tigray Catalonia Mekelle Barcelona Area [km2] 1.1 M 0.5 M 41 k 32 k 24.4 803 Population 90 M 47 M 4.3 M¤ 7.5 M 219 k 4.7 M ¤ 2007 Census. Source: Wikipedia. Llorenç Cerdà-Alabern Linux Routers and Community Networks 4 / 191 Introduction Where I come from Introduction A bit of history: Barcino Where I come from Linux Routers • Iberian, Carthaginian and Roman Town, called Barcino 15 BC. Llorenç Cerdà-Alabern Linux Routers and Community Networks 5 / 191 Introduction Where I come from Introduction Barcelona Where I come from Linux Routers Eixample Sagrada Familia Barça Llorenç Cerdà-Alabern Linux Routers and Community Networks 6 / 191 Introduction Where I come from Introduction Universitat Politècnica de Catalunya (UPC) Where I come from Linux Routers Campus Nord • UPC: Public University of Catalonia, focussed on tech. studies. • UPC has 22 Schools in 7 towns. • Facultat d’Informàtica de Barcelona (Computer Science) is in Campus Nord and has around 2,000 students. Llorenç Cerdà-Alabern Linux Routers and Community Networks 7 / 191 Summer Course at Mekelle Institute of Technology. Linux Routers and Community Networks Introduction Where I come from Part I Linux Routers Introduction Outline Where I come from Linux Routers Llorenç Cerdà-Alabern Linux Routers and Community Networks 8 / 191 Introduction Linux Routers Introduction Where I come from Linux Routers What is a Router? • Devices that use a common protocol: The Internet Protocol, IP. • Exchange Datagramans using any kind of physical network (LAN or WAN). • Interconnect IP Networks: Networks of devices having interfaces with unique addresses, sharing a common netid, or IP prefix (most significant bits of the IP address). Llorenç Cerdà-Alabern Linux Routers and Community Networks 9 / 191 Introduction Linux Routers Introduction IPv4 address Where I come from 0 bits 31 ++++++++++++++++ Linux Routers |netid| hostid| ++++++++++++++++ • 4 bytes (32 bits) • Dotted notation: 10.0.1.1, Mask: 255.255.255.0 or /24. • Host loopback network: 127.0.0.0/8. • Private add.: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16. netid hostid Class (bytes) (bytes) Codification range A 1 3 0xxxx x 0.0.0.0 127.255.255.255 ¢¢¢ » B 2 2 10xxx x 128.0.0.0 191.255.255.255 ¢¢¢ » C 3 1 110xx x 192.0.0.0 223.255.255.255 ¢¢¢ » D-- 1110x x 224.0.0.0 239.255.255.255 ¢¢¢ » E-- 1111x x 240.0.0.0 255.255.255.255 ¢¢¢ » Llorenç Cerdà-Alabern Linux Routers and Community Networks 10 / 191 Introduction Linux Routers Introduction IPv6 address Where I come 0 bits 127 from ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | netid| hostid| Linux Routers ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ • 16 bytes (128 bits) • Notation: ff02:0000:0000:0000:0000:0000:0000:0001/64 (8 quads of 4 nibbles). Simplification: supress leading and group zeroes: ff02::1/64 • Loopback: ::1/128 • Link local unicast: fe80::/10. Interface notation: fe80::4e5e:cff:fee9:fc89%eth0 • Unique local unicast (ULA): fc00::/7 (equivalent to private IPv4) • Global unicast: 2000::/3 • Multicast: ff00::/8 • Link local all nodes: ff02::1 Example: IPv6ll of all nodes in eth0: ping6 ff02::1%eth0 • Link local all routers: ff02::2 Llorenç Cerdà-Alabern Linux Routers and Community Networks 11 / 191 Introduction Linux Routers Introduction How a router works Where I come from Linux Routers ~# route -n Kernel IP routing table Destination Gateway Genmask Metric Iface 0.0.0.0 10.1.24.97 0.0.0.0 30 eth1.3 10.1.24.96 0.0.0.0 255.255.255.224 30 eth1.3 ~# ip r l default via 10.1.24.97 dev eth1.3 proto static metric 30 10.1.24.96/27 dev eth1.3 proto static scope link metric 30 Llorenç Cerdà-Alabern Linux Routers and Community Networks 12 / 191 Introduction Linux Routers Introduction Commertial routers Where I come from Linux Routers CISCO Juniper Llorenç Cerdà-Alabern Linux Routers and Community Networks 13 / 191 Introduction Linux Routers Introduction SOHO routers Where I come from Linux Routers CISCO Buffalo TP-link Mikrotik Huawei Ubiquiti Zyxel D-link ¢¢¢ Llorenç Cerdà-Alabern Linux Routers and Community Networks 14 / 191 Introduction Linux Routers Introduction Router Operating Systems Where I come from • CISCO: Internetwork Operating System, IOS. Linux Routers • Juniper: Junos OS. • Mikrotic: RouterOS. • Ubiquiti: AirOS. • Zyxel: ZyNOS. • Device specific: TP-Link, ¢¢¢ • Unix/Linuxa: Alpine, NetBSD, DD-WRT, EdgeOS, FREESCO, FreeWRT, OpenWrt, Tomato, . ¢¢¢ aSee Wikipedia: https://en.wikipedia.org/wiki/List_of_router_ and_firewall_distributions Llorenç Cerdà-Alabern Linux Routers and Community Networks 15 / 191 Introduction Linux Routers Introduction Where I come from Linux Routers Why OpenWrt? • GNU/Linux distribution originally designed for embedded devices. • Free, open source. • Active web page with a lot of documentationa. • Continuously improved by a wide and very active community. • Supported by a large number of devicesb. ahttps://openwrt.org/ bhttp://wiki.openwrt.org/toh/start Llorenç Cerdà-Alabern Linux Routers and Community Networks 16 / 191 Summer Course at Mekelle Institute of Technology. Linux Routers and Community Networks Lab 1: Basic Network Configuration Description Parts Unix basic commands I Introduction Lab set up II Lab 1: Basic Network Configuration Building a patch cord III Lab 2: RIP and OSPF Flashing OpenWrt IV Lab 3: Firewall configuration Accessing OpenWrt V Lab 4: Community Networks Installing VI Lab 5: Network Management packages OpenWrt Net. Interfaces Configure VLANs Configure WiFi StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 17 / 191 Summer Course at Mekelle Institute of Technology. Linux Routers and Community Networks Lab 1: Basic Network Part II Configuration Description Lab 1: Basic Network Configuration Unix basic commands Lab set up Building a Outline patch cord Flashing Description Installing packages OpenWrt Accessing Unix basic commands OpenWrt Net. Interfaces OpenWrt Installing Lab set up Configure VLANs packages OpenWrt Net. Building a patch cord Configure WiFi Interfaces Configure Flashing OpenWrt VLANs Static Routing Configure Accessing OpenWrt WiFi StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 18 / 191 Lab 1: Basic Network Configuration Description Lab 1: Basic Network Configuration Description Unix basic commands Objectives Lab set up • Basic Linux administration commands. Building a patch cord • Build a straight-through patch cord. Flashing OpenWrt • Install OpenWrt. Accessing • Configuring networking interfaces and static routing. OpenWrt Installing packages OpenWrt Net. Interfaces Configure VLANs Configure WiFi StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 19 / 191 Summer Course at Mekelle Institute of Technology. Linux Routers and Community Networks Lab 1: Basic Network Part II Configuration Description Lab 1: Basic Network Configuration Unix basic commands Lab set up Building a Outline patch cord Flashing Description Installing packages OpenWrt Accessing Unix basic commands OpenWrt Net. Interfaces OpenWrt Installing Lab set up Configure VLANs packages OpenWrt Net. Building a patch cord Configure WiFi Interfaces Configure Flashing OpenWrt VLANs Static Routing Configure Accessing OpenWrt WiFi StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 20 / 191 Lab 1: Basic Network Configuration Unix basic commands Lab 1: Basic Network Configuration Directories Description • cd: Change directory. Unix basic commands • mkdir: make directory, rmdir: remove directory. Lab set up • ls: list directory. Building a • patch cord rm: remove file, rm -r directory: remove directory and its Flashing contents. OpenWrt • chown: change owner file/directory. Accessing OpenWrt • chmod: change permissions. Installing Examples: chmod 700 file, chmod ugo+rwx file. packages • cat, more, less: dump file content. OpenWrt Net. Interfaces • df -h: list disk partitions. Configure VLANs Configure WiFi StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 21 / 191 Lab 1: Basic Network Configuration Unix basic commands Lab 1: Basic Network Files Configuration • grep: globally search regular expression (regex) and print, Description filter file content using regex. Unix basic ~# cat network | grep eth. commands option ifname ’eth0’ option ifname ’eth1’ Lab set up • find: find file. Examples: Building a patch cord ~# find . -name network ./config/network Flashing ./init.d/network OpenWrt ~# find /etc -name \*.conf -exec grep nameserver {} \; -print nameserver 127.0.0.1