Netzwerkgrundlagen Franz Schäfer LV Linux: Effiziente Anwendung an Hand von Fallbeispielen
Franz Schäfer ● ZID ● ISP (akis, silverserver,...) ● Nachtrichtentechnik, Regelungstechnik, Computertechnik ● Linux User seit 1995 (kernel )
Netzwerkgrundlagen ● Physische Verbindung – Ethernet, UTP, Wireless – Serielles Kabel – Tunnel (Virtuell) ● 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
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/network/options ip_forward=yes spoofprotect=no ● 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 # 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 ● IPv6 ● dynamisches routing ● VLANs ●...
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