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 Accessing /etc/resolv.conf OpenWrt Installing • sed: stream editor. packages ~# sed ’s/day/night/’
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 22 / 191 Lab 1: Basic Network Configuration Unix basic commands
Lab 1: Basic Network Configuration Processes Description • ps, top: show running processes. Unix basic • commands kill pid: kill process with process id pid.
Lab set up • killall cmd: kill command cmd. ~# top Building a Mem: 25404K used, 3608K free, 0K shrd, 964K buff, 4600K cached patch cord CPU: 1% usr 1% sys 0% nic 96% idle 0% io 0% irq 0% sirq Load average: 0.05 0.09 0.12 1/51 377 Flashing PID PPID USER STAT VSZ %VSZ %CPU COMMAND OpenWrt 8432 1 root S 2056 7% 1% /usr/sbin/bmx6 -f /etc/config/bmx6 -d Accessing 3 2 root SW 0 0% 0% [ksoftirqd/0] OpenWrt 27482 2 root SW 0 0% 0% [kworker/u2:2] 32763 32510 root R 1364 5% 0% top Installing 1200 1 root S 1360 5% 0% /usr/sbin/ntpd -n -p 0.openwrt.pool.n packages 32476 867 root S 1220 4% 0% /usr/sbin/dropbear -F -P /var/run/dro 923 1 root S 816 3% 0% /usr/bin/mini_snmpd -c public -d /jff OpenWrt Net. ... Interfaces ^C
Configure VLANs
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 23 / 191 Lab 1: Basic Network Configuration Unix basic commands
Lab 1: Basic Network Configuration Basic editing with vi • Two modes of operation: Description • insert mode: enter text. Unix basic • command mode: issue editing commands. commands • To switch into insert mode: Lab set up i insert before cursor. Building a patch cord I insert beginning of line.
Flashing a append after cursor. OpenWrt A append at end of line. Accessing • To switch into command mode, press ESC. OpenWrt • Saving and exiting: Installing packages :q quit.
OpenWrt Net. :q! quit discarding changes. Interfaces :w save file. After each change, it is recommended to save (there is no Configure undo). To abort changes and quit :q!. VLANs :w file write to file. Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 24 / 191 Lab 1: Basic Network Configuration Unix basic commands
Lab 1: Basic Network Basic editing with vi Configuration • Deleting: x character. Description dw word. Unix basic commands dd line.
Lab set up • Copy paste: yy yank (copy) line Building a patch cord yw yank word
Flashing v starting point for yank (y) or delete (d). OpenWrt p paste word after cursor, or line below. Accessing P paste word before cursor, or line above. OpenWrt • Installing Moving: packages 0 beginning of line.
OpenWrt Net. $ end of line. Interfaces gg beginning of file. Configure G end of file. VLANs :n go to line n. Configure WiFi • Repeat command, e.g. remove 3 characters: 3x.
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 25 / 191 Lab 1: Basic Network Configuration Unix basic commands
ssh session to Lab 1: Basic configure the router Network Configuration OpenWrt Dropbear ssh server Description ssh and scp Unix basic commands • Configuration files:
Lab set up ~# ls ~/.ssh authorized_keys config id_rsa id_rsa.pub known_hosts Building a patch cord • Generates key pair (id_rsa, id_rsa.pub): Flashing ~# ssh-keygen-t rsa OpenWrt
Accessing • Connect to IP 192.168.1.1, user root: OpenWrt ~# ssh 192.168.1.1-l root Installing packages • ssh key pair can be used to connect without password appending _ _ OpenWrt Net. id rsa.pub to remote file .ssh/authorized keys: Interfaces ~# cat id_rsa.pub| ssh [email protected]’cat- >>.ssh/authorized _keys’ Configure VLANs • Recursively copy to remote host:
Configure ~# scp-r config [email protected]:/tmp WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 26 / 191 Lab 1: Basic Network Configuration Unix basic commands
Lab 1: Basic Network Configuration Linux basic networking configuration • List all interfaces: Description ~# ifconfig-a Unix basic commands • Assign IP address:
Lab set up ~# ifconfig eth0 102.168.1.2 netmask 255.255.255.240 Building a • List routing table: patch cord ~# route-n Flashing Kernel IP routing table OpenWrt Destination Gateway Genmask Flags Metric Ref Use Iface Accessing 0.0.0.0 192.168.2.1 0.0.0.0 UG 0 0 0 wlan0 OpenWrt 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan Installing • Add a default route: packages ~# route add default gw 192.168.2.1 OpenWrt Net. Interfaces • Add/delete a static route: Configure ~# route add-net 10.0.0.0 netmask 255.255.255.0 gw 192.168.2.1 VLANs ~# route del-net 10.0.0.0 netmask 255.255.255.0 gw 192.168.2.1
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 27 / 191 Lab 1: Basic Network Configuration Unix basic commands
Lab 1: Basic Network ip command Configuration • Replaces and add functionalities to ifconfig and route.
Description # list IPv6 addresses root@OpenWrt:~# ip -6 a l Unix basic 1: lo:
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 28 / 191 Lab 1: Basic Network Configuration Unix basic commands
Lab 1: Basic Network Configuration
Description arp Unix basic • List stations from the network with whom datagrams have commands been exchanged: Lab set up # legacy arp command Building a ~# arp patch cord IP address HW type Flags HW address Mask Device Flashing 192.168.1.234 0x1 0x2 00:24:e8:2c:74:e2 * br-lan OpenWrt 192.168.2.1 0x1 0x2 d4:ca:6d:a1:dc:e0 * wlan0 192.168.2.20 0x1 0x2 dc:9f:db:28:81:cd * wlan0 Accessing # using ip OpenWrt ~# ip neigh l 192.168.1.234 dev br-lan lladdr 00:24:e8:2c:74:e2 STALE Installing 192.168.2.1 dev wlan0 lladdr d4:ca:6d:a1:dc:e0 STALE packages 192.168.2.20 dev wlan0 lladdr dc:9f:db:28:81:cd STALE
OpenWrt Net. Interfaces
Configure VLANs
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 29 / 191 Lab 1: Basic Network Configuration Unix basic commands
Lab 1: Basic Network Check for connectivity: ping, traceroute, mtr Configuration • List stations from the network with whom datagrams have Description been exchanged:
Unix basic ~# ping 8.8.8.8 commands PING 8.8.8.8 (8.8.8.8): 56 data bytes 64 bytes from 8.8.8.8: seq=0 ttl=45 time=54.281 ms Lab set up 64 bytes from 8.8.8.8: seq=1 ttl=45 time=58.195 ms Building a ^C patch cord --- 8.8.8.8 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss Flashing round-trip min/avg/max = 54.281/56.238/58.195 ms OpenWrt ~# traceroute-n 8.8.8.8 traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 38 byte packets Accessing 1 10.228.205.1 5.807 ms 2.924 ms 2.875 ms OpenWrt 2 *** 3 10.253.4.22 5.145 ms 6.577 ms 6.800 ms Installing 4 62.115.43.113 8.434 ms 7.654 ms 4.084 ms packages 5 80.91.254.120 22.554 ms 80.91.253.97 22.552 ms 80.91.247.14 48.658 ms 6 62.115.143.210 34.897 ms 62.115.139.59 48.477 ms 80.91.246.182 46.697 ms OpenWrt Net. 7 62.115.134.65 67.621 ms 80.91.249.89 55.958 ms 213.155.134.114 54.432 ms Interfaces 8 80.91.253.54 48.835 ms 213.155.135.87 49.264 ms 213.155.135.83 47.000 ms Configure 9 213.248.85.118 45.592 ms 45.500 ms 50.965 ms VLANs 10 72.14.233.127 48.323 ms 54.649 ms 44.920 ms 11 8.8.8.8 45.559 ms 44.919 ms 45.512 ms Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 30 / 191 Lab 1: Basic Network Configuration Unix basic commands
Lab 1: Basic Network Domain Name System, DNS Configuration • File /etc/hosts:
Description ~# cat/etc/hosts 127.0.0.1 localhost Unix basic 127.0.1.1 tramuntana.local tramuntana commands 192.168.1.1 tp-link Lab set up • File resolv.conf: Building a ~# cat/etc/resolv.conf patch cord search lan nameserver 192.168.1.1 Flashing OpenWrt • File resolv.conf.auto: Accessing ~# cat/tmp/resolv.conf.auto OpenWrt # Interface wwan nameserver 212.68.193.110 Installing nameserver 212.68.193.196 packages
OpenWrt Net. • Asking the resolver with nslookup: Interfaces ~# nslookup Configure > set type=MX VLANs > cisco.com ... Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 31 / 191 Lab 1: Basic Network Configuration Unix basic commands
Lab 1: Basic Network WiFi Review Configuration • Use the Industrial Scientific and Medical (ISM) band: 2.4 GHz
Description and 5 GHz.
Unix basic • Basic Service Set (BSS): Set of stations communicating with commands each other. If the network is composed of more than 1 BSS it is Lab set up called Extended Service Set (ESS). Building a patch cord • BSS are identified by: (i) a Service Set identifier (SSID), or Flashing Network name: String with <32 characters; and (ii) a BSS OpenWrt Identifier (BSSID): 48 bits number. Accessing OpenWrt
Installing packages
OpenWrt Net. Interfaces
Configure VLANs Infrastructure BSS Independent BSS, IBSS Configure (infrastructure mode). (ad-hoc mode). WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 32 / 191 Lab 1: Basic Network Configuration Unix basic commands
Lab 1: Basic Network Configuration WiFi Commands • Connected stations: iwinfo: Description ~# iwinfo wlan0 ESSID: "gubia" Unix basic Access Point: 0C:82:68:CD:A1:06 commands Mode: Client Channel: 11 (2.462 GHz) Tx-Power: 20 dBm Link Quality: 36/70 Lab set up Signal: -74 dBm Noise: unknown Building a Bit Rate: 48.0 MBit/s patch cord ... Flashing • Configuration and scanning: iw: OpenWrt ~# iw wlan0 scan Accessing BSS 0c:82:68:cd:a1:06(on wlan0) -- associated OpenWrt TSF: 60669050681 usec (0d, 16:51:09) freq: 2462 Installing beacon interval: 100 TUs packages capability: ESS Privacy ShortPreamble ShortSlotTime (0x0431) OpenWrt Net. signal: -72.00 dBm Interfaces last seen: 420 ms ago Information elements from Probe Response frame: Configure SSID: gubia VLANs ...
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 33 / 191 Lab 1: Basic Network Configuration Unix basic commands
Lab 1: Basic Network Troubleshooting Configuration • tcpdump of a TCP segment: seq number payload length Description flags TCP seq number (bytes) next segment advertized dst port Unix basic src port window commands src IP address dst IP address timestamp Lab set up 16:43:02.126531 147.83.34.125.2628 > 147.83.30.137.80: S 903489440:903489440(0) win 5840
Configure ~# tcpdump-vni br-lan port 67 VLANs tcpdump: listening on br-lan, link-type EN10MB (Ethernet), capture size 65535 bytes 14:24:56.571518 IP (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 328) Configure 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 10:fe:ed:af:63:5e, length 300, xid 0x6aaf8c2c, Flags [none] WiFi ...
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 34 / 191 Lab 1: Basic Network Configuration Unix basic commands
Lab 1: Basic Network Configuration Troubleshooting Description • System logs. In OpenWrt: Unix basic commands ~# logread Tue Jun 9 13:25:41 2015 daemon.notice netifd: Interface ’wwan’ is enabled Lab set up Tue Jun 9 13:25:41 2015 kern.info kernel: [ 1003.250000] wlan0: authenticate with 0c:82:68:cd:a1:06 ... Building a patch cord • netperf. Throughput of a link using the IPv6 link local with a Flashing OpenWrt 1 s test: ~# netperf-l1-H fe80::12fe:edff:feaf:635e%eth0 Accessing MIGRATED TCP STREAM TEST from ::0 (::) port 0 AF_INET6 to fe80::12fe:edff:feaf:635e%eth0 () port 0 AF_INET6 : demo OpenWrt Recv Send Send Socket Socket Message Elapsed Installing Size Size Size Time Throughput packages bytes bytes bytes secs. 10^6bits/sec OpenWrt Net. Interfaces 87380 16384 16384 1.05 92.75
Configure VLANs
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 35 / 191 Lab 1: Basic Network Configuration Unix basic commands
Lab 1: Basic Network Configuration
Description
Unix basic commands Gnu screen Lab set up • Allows multiplexing a physical terminal in different windows. Building a patch cord Gnu screen initialization file:
Flashing ~# echo’caption always "%{= kw}%-w%{=BW}%n%t%{-}%+w %-=@%H-%LD%d%%LM-%c"’>.screenrc OpenWrt • The screen basic commands are the following (C-a c means Accessing OpenWrt type Control and a simultaneously, release and type c):
Installing C-a c create new window. packages C-d close window. OpenWrt Net. C-a 0 change to window number 0 (likewise for windows 0-9). Interfaces C-a p change to previous window. Configure C-a n change to next window. VLANs C-a k kill current window. Configure WiFi C-a A rename current window.
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 36 / 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 37 / 191 Lab 1: Basic Network Configuration Lab set up
G5 G6 Lab 1: Basic PC3 R5 R6 PC3 10.5.3.0/24 10.6.3.0/24 STAP ST ST Network PC2 .2 .1 .1 .2 PC2 CH132 10.5.2.0/24 .1 .1 10.6.2.0/24 .2 Configuration .5 .1 .2 .5 .2 .1 .1 PC1 192.168.5.0/24 10.5.1.0/24 10.6.1.0/24 PC1 .2 .2
Description G4 G7 PC3 R4 R7 PC3 10.4.3.0/24 ST ST 10.7.3.0/24 Unix basic PC2 .2 .1 AP ST .1 .2 PC2 CH124 10.4.2.0/24 .1 .1 10.7.2.0/24 .2 commands Objectives: .4 .1 .2 .4 .2 .1 .1 PC1 192.168.4.0/24 10.4.1.0/24 10.7.1.0/24 PC1 Lab set up • We want to set up .2 .2
Building a G3 G8 this network. PC3 R3 R8 PC3 patch cord 10.3.3.0/24 ST ST 10.8.3.0/24 PC2 .2 .1 AP ST .1 .2 PC2 10.3.2.0/24 .1 CH116 .1 10.8.2.0/24 .2 Flashing .3.1 .2 .3 • Using static .2 .1 PC1 .1 OpenWrt 10.3.1.0/24 192.168.3.0/24 10.8.1.0/24 PC1 routing. .2 .2 Accessing OpenWrt G2 G9 • PC3 R2 R9 PC3 Following the 10.2.3.0/24 ST ST 10.9.3.0/24 Installing PC2 .2 .1 AP ST .1 .2 PC2 10.2.2.0/24 .1 CH108 .1 10.9.2.0/24 .2 .2 .1 .2 .2 packages guidelines in the .2 .1 PC1 .1 10.2.1.0/24 192.168.2.0/24 10.9.1.0/24 PC1 .2 .2 OpenWrt Net. next slides. Interfaces G1 G10 PC3 R1 R10 PC3 Configure 10.1.3.0/24 AP AP 10.10.3.0/24 PC2 .2 AP ST .2 .1 .1 PC2 VLANs 10.1.2.0/24 .1 CH100 .1 10.10.2.0/24 .2 .1 .1 .2 .1 .2 .1 .1 PC1 192.168.1.0/24 Configure 10.1.1.0/24 10.10.1.0/24 PC1 .2 CH1 CH6 .2 WiFi Internet .1 192.168.6.0/24 192.168.7.0/24 200.0.0.0/24 StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 38 / 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 39 / 191 Lab 1: Basic Network Configuration Building a patch cord
Lab 1: Basic Network Configuration
Description 12 3 4 8765
Unix basic commands Building a straight-through patch cord Lab set up Building a Pin Pair Cable Color patch cord 1 1 white/orange Flashing 2 OpenWrt 2 2 orange
Accessing 3 3 1 white/green OpenWrt 4 2 blue 1 Installing 5 1 white/blue packages 6 3 2 green OpenWrt Net. Interfaces 7 1 white/brown 4 Configure 8 2 brown VLANs
Configure Table: RJ45 EIA/TIA-568B pinout. WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 40 / 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 41 / 191 Lab 1: Basic Network Configuration Flashing OpenWrt
Lab 1: Basic Network Configuration 192.168.0.2/24 eth0
Description TL−WDR4300 router 192.168.0.1/24 Unix basic commands Flashing OpenWrt into TL-WDR4300 Lab set up
Building a 1 Download the OpenWrt image: patch cord https://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/ openwrt-ar71xx-generic-tl-wdr4300-v1-squashfs-factory.bin Flashing OpenWrt 2 Assign the IP address to the PC.
Accessing 3 Log into the WDR4300 at 192.168.0.1 using admin:admin OpenWrt 4 System Tools -> Firmware Upgrade. Installing 5 Browse -> packages select the firmware. 6 Upgrade -> OK. OpenWrt Net. Interfaces 7 You will then see the firmware upgrade in progress. Configure 8 After a couple of minutes this should switch to Software Upgraded VLANs Successfully! and restart. Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 42 / 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 43 / 191 Lab 1: Basic Network Configuration Accessing OpenWrt
Lab 1: Basic Network ssh session to Configuration configure the router
Description
Unix basic OpenWrt commands Dropbear ssh server
Lab set up Finding the local link local IPv6 Building a patch cord 1 Check the IPv6 link local of the local interface eth0: Flashing ~# ip -6 a l dev eth0 OpenWrt 2: eth0:
Installing 2 If no IPv6 link local is assigned, check that the kernel variable packages net.ipv6.conf.eth0.disable_ipv6 is set to 0: OpenWrt Net. _ Interfaces ~# sysctl -a | grep net.ipv6.conf.eth0.disable ipv6 net.ipv6.conf.eth0.disable_ipv6 = 1 Configure ~# sysctl -w net.ipv6.conf.eth0.disable_ipv6=0 VLANs
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 44 / 191 Lab 1: Basic Network Configuration Accessing OpenWrt
Lab 1: Basic Network Configuration Finding the OpenWrt router link local IPv6
1 ping to IPv6 multicast all hosts. Description ~# ping6 -c 2 ff02::1%eth0 Unix basic PING ff02::1%eth0(ff02::1) 56 data bytes commands 64 bytes from fe80::250:daff:fec9:6ec7: icmp_seq=1 ttl=64 time=0.027 ms 64 bytes from fe80::12fe:edff:feaf:635e: icmp_seq=1 ttl=64 time=0.279 ms (DUP!) Lab set up 64 bytes from fe80::250:daff:fec9:6ec7: icmp_seq=2 ttl=64 time=0.029 ms Building a patch cord --- ff02::1%eth0 ping statistics --- 2 packets transmitted, 2 received, +1 duplicates, 0% packet loss, time 999ms Flashing rtt min/avg/max/mdev = 0.027/0.111/0.279/0.118 ms OpenWrt 2 You can try to ping to IPv6 multicast all routers. Accessing OpenWrt ~# ping6 ff02::02%eth0 PING ff02::02%eth0(ff02::2) 56 data bytes Installing 64 bytes from fe80::12fe:edff:feaf:635e: icmp_seq=1 ttl=64 time=0.627 ms packages 64 bytes from fe80::12fe:edff:feaf:635e: icmp_seq=2 ttl=64 time=0.333 ms OpenWrt Net. ^C Interfaces --- ff02::02%eth0 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms Configure rtt min/avg/max/mdev = 0.333/0.480/0.627/0.147 ms VLANs
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 45 / 191 Lab 1: Basic Network Configuration Accessing OpenWrt
Lab 1: Basic Network Configuration
Description
Unix basic Assign a password to the OpenWrt router commands 1 Assign a password to the OpenWrt router using telnet: Lab set up ~# telnet fe80::12fe:edff:feaf:635e%eth0 Building a root@OpenWrt:/# passwd patch cord Changing password for root New password: 13f Flashing Bad password: too short OpenWrt Retype password: 13f Accessing Password for root changed by root OpenWrt root@OpenWrt:/# ^D root@OpenWrt:/# Connection closed by foreign host. Installing packages
OpenWrt Net. Interfaces
Configure VLANs
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 46 / 191 Lab 1: Basic Network Configuration Accessing OpenWrt
Lab 1: Basic Network Accessing the OpenWrt router with the command line interface Configuration (CLI) and web interface (WI)
Description 1 We need to forward ports with ssh to access with the WI.
Unix basic ~# ssh -L 8080:[::1]:80 fe80::12fe:edff:feaf:635e%eth0 -l root commands The authenticity of host ’fe80::12fe:edff:feaf:635e%eth0 (fe80::12fe:edff:feaf:635e%eth0)’ can’t be established. RSA key fingerprint is b1:b5:d3:f0:1b:03:5c:dc:ff:bd:2a:c5:14:45:c3:76. Lab set up Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added ’fe80::12fe:edff:feaf:635e%eth0’ (RSA) to the list of known hosts. Building a root@fe80::12fe:edff:feaf:635e%eth0’s password: 13f patch cord
Flashing 2 Use the URL http://localhost:8080 to access the WI with the OpenWrt browser. Accessing OpenWrt
Installing packages
OpenWrt Net. Interfaces
Configure VLANs
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 47 / 191 Lab 1: Basic Network Configuration Accessing OpenWrt
Lab 1: Basic Network Configuration Disable the firewall using the WI System -> Startup -> firewall -> Enable & Stop Description
Unix basic commands
Lab set up
Building a patch cord Configure the router name Flashing OpenWrt System -> Hostname -> Save & Apply Accessing OpenWrt
Installing packages
OpenWrt Net. Interfaces
Configure VLANs
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 48 / 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 49 / 191 Lab 1: Basic Network Configuration Installing packages
Lab 1: Basic Network Configuration 1 Connect the Internet Ethernet port of the router to the Internal network. The router should be configured by DHCP and have Description access to the Internet. Unix basic commands 2 Install the packages: tcpdump, ip, netperf and screen. Lab set up System -> Software -> Update list -> Find Building a patch cord
Flashing OpenWrt
Accessing OpenWrt
Installing packages
OpenWrt Net. Interfaces
Configure VLANs 3 Activate the netperf server: System -> Startup... Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 50 / 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 51 / 191 Lab 1: Basic Network Configuration OpenWrt Net. Interfaces
Lab 1: Basic Network Configuration Linux kernel distinguishes two type of interfaces 1 Physical Network Interfaces: As soon as the device driver is Description loaded into the Kernel a corresponding physical network Unix basic interface becomes present, e.g. eth0, wlan0, etc. commands 2 Virtual Network Interfaces: Introduced for the sake of flexibility. Lab set up Associated with a physical network interface, another virtual Building a patch cord interface, or be stand alone such as the loopback interface lo.
Flashing OpenWrt • The Unified Configuration Interface, UCI, is a small C utility Accessing OpenWrt designed to centralize configuration in OpenWrt. Installing • /etc/config/network is the network configuration file. packages
OpenWrt Net. • /etc/config/wireless is the wireless configuration file. Interfaces • UCI creates an abstraction layer for configuring network interfaces: Configure VLANs In /etc/config/network you allocate a name like lan or wan. Then
Configure this name is consistently used through the entire UCI configuration. WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 52 / 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 53 / 191 Lab 1: Basic Network Configuration Configure VLANs
Lab 1: Basic Network Configuration What are VLANs?
Description
Unix basic commands
Lab set up
Building a patch cord Flashing • OpenWrt Each port belongs to a VLAN.
Accessing • The switch isolates different VLANs: Each VLAN is equivalent OpenWrt to a different physical switch. A router is needed to send traffic Installing packages to a different VLAN.
OpenWrt Net. • The port configured as trunk belongs to several VLANs. Interfaces • The traffic sent in one VLAN is also sent to the trunk the VLAN Configure VLANs belongs to. A tagging mechanism is used in the trunk to
Configure discriminate the traffic from different VLANs. WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 54 / 191 Lab 1: Basic Network Configuration Configure VLANs
Lab 1: Basic Network Configuration
Default TP-Link TL-WDR4300 VLAN configuration Description
Unix basic commands
Lab set up
Building a patch cord
Flashing OpenWrt eth0.1 eth0.2 not used Accessing OpenWrt
Installing packages
OpenWrt Net. Interfaces
Configure VLANs
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 55 / 191 Lab 1: Basic Network Configuration Configure VLANs
Lab 1: Basic Network Configuration
Description 1 Using the WI, configure Ethernet ports 1, 2, 3, 4 of the router in
Unix basic VLANs 1, 2, 3, 4, and the Internet port in VLAN 5. Note that commands originally the Internet port of the router is configured in VLAN 2. Lab set up Network -> Switch -> Add -> -> Save & Apply Building a ··· patch cord
Flashing OpenWrt
Accessing OpenWrt
Installing packages
OpenWrt Net. Interfaces
Configure VLANs
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 56 / 191 Lab 1: Basic Network Configuration Configure VLANs
Lab 1: Basic Network Create Interfaces for the VLANS Configuration 1 Using the WI, create the virtual interfaces LAN1, LAN2, LAN3, LAN3 eth0.1 eth0.2 Description associated with physical interfaces , , eth0.3, eth0.4. Configure them with unmanaged protocol. Unix basic commands Associate the wan interface with eth0.5. In the end, delete the LAN Lab set up interface, reboot and connect again. The new interfaces should show
Building a up configured only with IPv6 link local addresses: patch cord root@OpenWrt:~# reboot; exit Flashing ~# ssh -L 8080:[fe80::12fe:edff:feaf:635e%eth0]:80 fe80::12fe:edff:feaf:635e%eth0 -l root OpenWrt root@OpenWrt:~# ipal ... Accessing 5: eth0.1@eth0:
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 58 / 191 Lab 1: Basic Network Configuration Configure WiFi
Lab 1: Basic Network Configuring a WiFi AP Configuration 1. Network -> wifi -> Edit 2. Advanced Settings
Description
Unix basic commands
Lab set up
Building a patch cord
Flashing OpenWrt
Accessing OpenWrt 3. Save & Apply, Enable See appendix A for channels. Installing packages
OpenWrt Net. Interfaces
Configure VLANs
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 59 / 191 Lab 1: Basic Network Configuration Configure WiFi
Lab 1: Basic Network Configuring a wifi station Configuration 1. Network -> wifi 2. scan
Description
Unix basic commands
Lab set up
Building a patch cord
Flashing OpenWrt
Accessing OpenWrt Installing 3. Join Network 4. submit. packages
OpenWrt Net. Interfaces
Configure VLANs
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 60 / 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 61 / 191 Lab 1: Basic Network Configuration Static Routing
Lab 1: Basic Network Configuration Configuration of IP addresses and routing tables
Description 1 Use the CLI to configure the IP addresses and router table
Unix basic entries. Try with traditional commands (ifconfig, route), and commands ip command. Lab set up 2 Configure the PCs manually (with ip command), setting the Building a patch cord router where they are connected as default gateway. Flashing OpenWrt 3 Each router must end up with the 37 networks and a default Accessing route towards the laptop that represents the Internet. All hosts OpenWrt must be reachable. Installing packages 4 Convection for the gateways: a router in the same column to OpenWrt Net. reach networks in the same side, a router in the same row to Interfaces reach networks in the opposite side. For instance, R1 chooses Configure VLANs R5 to reach 10.5.1.0/24, and R10 to reach 10.6.1.0/24.
Configure WiFi
StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 62 / 191 Lab 1: Basic Network Configuration Static Routing
G5 G6 Lab 1: Basic PC3 R5 R6 PC3 10.5.3.0/24 10.6.3.0/24 STAP ST ST Network PC2 .2 .1 .1 .2 PC2 CH132 10.5.2.0/24 .1 .1 10.6.2.0/24 .2 Configuration .5 .1 .2 .5 .2 .1 .1 PC1 192.168.5.0/24 10.5.1.0/24 10.6.1.0/24 PC1 .2 .2
Description G4 G7 PC3 R4 R7 PC3 10.4.3.0/24 ST ST 10.7.3.0/24 Unix basic PC2 .2 .1 AP ST .1 .2 PC2 CH124 10.4.2.0/24 .1 .1 10.7.2.0/24 .2 commands .4 .1 .2 .4 .2 .1 .1 PC1 192.168.4.0/24 10.4.1.0/24 10.7.1.0/24 PC1 Lab set up .2 .2 Objectives: Building a G3 G8 patch cord PC3 R3 R8 PC3 • We want to set up 10.3.3.0/24 ST ST 10.8.3.0/24 PC2 .2 .1 AP ST .1 .2 PC2 10.3.2.0/24 .1 CH116 .1 10.8.2.0/24 .2 Flashing .3.1 .2 .3 .2 .1 PC1 .1 OpenWrt this network. 10.3.1.0/24 192.168.3.0/24 10.8.1.0/24 PC1 .2 .2 Accessing • Using static OpenWrt G2 G9 PC3 R2 R9 PC3 routing. 10.2.3.0/24 ST ST 10.9.3.0/24 Installing PC2 .2 .1 AP ST .1 .2 PC2 10.2.2.0/24 .1 CH108 .1 10.9.2.0/24 .2 .2 .1 .2 .2 packages .2 .1 PC1 .1 10.2.1.0/24 192.168.2.0/24 10.9.1.0/24 PC1 .2 .2 OpenWrt Net. Interfaces G1 G10 PC3 R1 R10 PC3 Configure 10.1.3.0/24 AP AP 10.10.3.0/24 PC2 .2 AP ST .2 .1 .1 PC2 VLANs 10.1.2.0/24 .1 CH100 .1 10.10.2.0/24 .2 .1 .1 .2 .1 .2 .1 .1 PC1 192.168.1.0/24 Configure 10.1.1.0/24 10.10.1.0/24 PC1 .2 CH1 CH6 .2 WiFi Internet .1 192.168.6.0/24 192.168.7.0/24 200.0.0.0/24 StaticLlorenç Routing Cerdà-Alabern Linux Routers and Community Networks 63 / 191