Netzwerke und Netzwerktools Franz Schäfer LV Linux: Effiziente Anwendung anhand von Fallbeispielen
Franz Schäfer ● IST. Austria ● ZID WU ● ISP (akis, silverserver,...) ● Nachtrichtentechnik, Regelungstechnik, Computertechnik ● Linux User seit 1995 (kernel )
Netzwerkgrundlagen ● Physische Verbindung – Ethernet, UTP, Wireless ("broadcast") – Serielles Kabel, Tunnel (Virtuell) ("point to point") ● Interface ● Netzwerkstack (z.B.: TCP/IP) ● Applikation (z.B.: Web-Browser )
ISO-OSI Modell
ifconfig # ifconfig eth0 Link ap:Ethernet HWaddr 00:0E:2E:6C:BD:51 inet addr: Bcast: Mask: UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets: errors:0 dropped:0 overruns:0 frame:0 TX packets: errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes: TX bytes: Interrupt:10
ifconfig ● Anzeige der (aktiven) Netzwerkinterfaces ● Details zu den Interfaces – MAC Adresse – IP Adresse – Eingehende, Ausgehende Packete ● Veränderung der Interface-Einstellungen
Exkurs Ethernet ● Mehrere Netzwerkknoten “sehen” sich direkt ● Addressierung über MAC-Addresse – z.B.: A3:07:56:3C:F3:02 ● Broadcasts (“an alle”) möglich Switch oder Hub
TCP/IP (v4) ● 2^32 Adressen: geschrieben als 256^4 in Notation: – z.B.: – Keine gültige Adresse: ● Auf Ethernet: Zuordnung zwischen MAC- Addressen und IP Addressen via arp (address resolution protocol) – Befehl: arp -n
Einschub IPv6 # host -t AAAA :6B0:1:EA:202:A5FF:FECD:13A6 128 bit adressen geschrieben als 8 mal 4hex stellen. Tools: ping6, traceroute6, "ip -6" ● native vs. tunnel ● 6to4 tunnel 2002:
Ipv6 vor und nachteile ● noch wenige hosts native v6 erreichbar. ● /48 für endkundInnen ● privacy?
CIDR ● Classless Internet Domain Routing ● /24 = XXX ● /16 = WU-Netz = xxx.xxx ● /25 = bis ● Alternativ: Netmask:
Exkurs: Private IP Space ● – – /8 oder = mal /24 ● – – /12 = 1024 mal /24 ● – – /16 = 256 mal /24 ● Beispiel: Heimnetz: – /24 ● Nicht im Internet geroutet => NAT
alias interface # ifconfig eth0: \ netmask \ broadcast
tcpdump – traffic ansehen tcpdump -ni eth0 not port 22 13:40: IP > : UDP, length 12 13:40: IP > : 16832% [1au] AAAA? dns.mond.at. (40) 13:40: IP > : 16832* 0/1/1 (88) 13:40: arp who-has (ff:ff:ff:ff:ff:ff) tell :40: IP > : MX? area23.mond.at. (32)
ping # ping PING ( ) 56(84) bytes of data. 64 bytes from mu-in-f147.google.com ( ): icmp_seq=1 ttl=241 time=22.6 ms 64 bytes from mu-in-f147.google.com ( ): icmp_seq=2 ttl=241 time=22.6 ms
traceroute traceroute traceroute to ( ), 30 hops max, 40 byte packets 1 gw wu-wien.ac.at ( ) ms ms ms 2 box-1-19.wu-wien.ac.at ( ) ms ms ms mu-in-f103.google.com ( ) ms ms ms
route - wie die packete ihren weg finden route = Wegweiser für IP-Netze / / /24 erreichbar via /24 erreichbar via
route beispiele # route -n # route add default gw # route add -net /24 \ gateway
ip forwarding einschalten ● default i.a.: packete nicht weiterleiten + spoof protection ● in /etc/sysctl.conf net.ipv4.ip_forward=1 net.ipv4.conf.all.rp_filter=1 ● oder echo 1 > /proc/sys/net/ipv4/ip_forward echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
dhcp ● server: vergibt IP adressen, routen, nameserver ● client: holt sich alles was gebraucht wird # dhclient eth0 (alte distribution # pump eth0)
ifup / ifdown # ifup eth1 # ifup -a datei: /etc/network/interfaces auto lo iface lo inet loopback auto eth1 iface eth1 inet dhcp
/etc/network/interfaces auto eth0 iface eth0 inet static address network netmask broadcast gateway up /root/myfirwall.sh
troubleshooting step by step ● ifconfig eth0 – funktioniert? – modprobe – wireless: iwconfig, wpa_supplicant ● IP addressen im ifconfig richtig? – dhclient, pump ● route -n richtig?
troubleshooting part2 ● ifconfig zeigt eingehende packete? ● tcpdump -ni zeigt packete? ● ping auf lokalen rechner (am besten gateway) ist möglich? ● arp -n zeigt Mac Addresse des gateways? ● dns problem (name statt IP)
TCP, UDP, Port Nummern ● TCP – Verbindungsorientiert ● UDP – Einzelne (Datagram) packete ● Jedes Service hat ein Port: – wie die Türnummer zu einer Hausnummer – 80 www (http) – 25 mail (smtp)
Portnummern, netstat ● Ports: – 21 ftp – 22 ssh – 23 telnet – 80 http ● welche ports sind offen? – # netstat -nt --listen -p – # netstat -nu --listen -p
Beispiel: ADSL Verbindung in /etc/network/interfaces iface eth0 inet static address netmask testen mit # ping (computer) zu (adsl modem)
ADSL Verbindung pptp ● in /etc/ppp/peers/meinprovider user LoginNameZumProvider noauth noipdefault defaultroute persist maxfail 0 noproxyarp pty "/usr/sbin/pptp – nolaunchpppd" ● in /etc/ppp/pap-secrets LoginNameZumProvider * PassWort Verbinden: /usr/sbin/pppd call meinprovider
ADSL P-t-P Interface # ifconfig zeigt nun: ppp0 Link encap:Point-to-Point Protocol inet addr: P-t-P: Mask: debuging: in config file “debug” schreiben und / var/log/syslog, /var/log/messages oder /var/log/debug mittels tail -f anschauen
Zusammenfassung – ISO-OSI Modell – ifconfig – Ethernet – TCP/IP – CIDR – Private Space IP – alias Interface – tcpdump – ping – traceroute – route – dhcp – ifup /ifdown – troubleshooting – TCP, UDP, Portnummern – Beispiel ADSL PtP
Nützliche Links dlhp/HOWTO/DE-Netzwerk-HOWTO.html
Mögliche Vertiefungen ● iptables – firewalling, NAT ● dynamisches routing ● VLANs ●...
iptables aufbau
iptables - übersicht # iptables -L -n # iptables -L -n -t nat anzeigen der tables # iptables -F flush # iptables -I INPUT -j DROP -i eth1 -p tcp --dport 22 -s 0/0 # iptables -I INPUT -j ACCEPT -s /24 -p tcp --dport 22 sperre aller zugriffe auf ssh ausser von einem netz
iptables nat # iptables -t nat -I POSTROUTING -j SNAT \ -s /8 -d ! /8 \ --to-source # iptables -t nat -I POSTROUTING \ -j MASQUERADE -s /24 \ --out-interface eth1
dynamisches routing ● intern: RIP, OSPF ● extern (zwischen providern): BGP linux software: ● quagga ● zebra ● bird
VLANs problem: mehrere unabhaengige netze am selben kabel (z.b. verbindung von switchen oder servern die in viele LANs "sehen" wollen) Trunk port: 12 bit (4096) VLAN id in ethernet packet. IEEE 802.1q
VLAN tagged vs. untagged
linux vlan commands # ifconfig eth0 up # vconfig add eth0 101 # vconfig add eth0 201 # ifconfig eth0.101 \