Top Banner
Компютърни Мрежи и GNU/Linux Боян Кроснов [email protected] http://boyan.krosnov.org/ Мариян Маринов [email protected] SiteGround LLC
34

Компютърни Мрежи и GNU/Linux Боян Кроснов [email protected] Мариян Маринов [email protected] SiteGround LLC.

Jan 01, 2016

Download

Documents

Eleanore Barker
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

Компютърни Мрежи и GNU/Linux

Боян Кроснов

[email protected] http://boyan.krosnov.org/

Мариян Маринов

[email protected] LLC

Page 2: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

2

Лекцията

Преговор Linux Networking Stack Команди – IP ARP протокол Команди – ARP Sniffers TCP и UDP протоколи Команди – TCP и UDP

Page 3: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

3

Преговор

Page 4: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

4

Слоести мрежови модели

1. Physical

2. Datalink

3. Network

4. Transport

5. Session

6. Presentation

7. Application

Page 5: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

5

Page 6: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

6

Протоколи

1. baseband, *PSK, QAM-*, OFDM, CDMA, etc. overCat5, Fiber, HFC, phone line, RF etc.

2. Ethernet (802.3) , 802.11, 802.15, 802.16, PPP

3. IP/IPv6

4 and 5. TCP, UDP, RTP

7. HTTP, FTP, SMTP, POP3, IMAP4, SIP, XMPP, IRC, SNMP, SSH, TELNET, DNS, NTP, DHCP

Page 7: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

7

Мрежова топология

router

subnet, (V)LAN

hosthost

host

host

subnet, (V)LAN

host host

host

subnet, (V)LAN

host

host

host

hostsubnet, (V)LAN

router

Page 8: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

8

Команди

lspci ip link ethtool, mii-tool ifconfig; /proc/net/dev vconfig; /proc/net/vlan

Page 9: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

9

Demo setup

Ethernet LAN

luna

Wireless LAN

boyangamelon

Page 10: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

10

Ethernet LAN

luna

Wireless LAN

boyangamelon

10.126.0.0/24.1 .2 10.126.1.0/24.1 .2

Page 11: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

11

NIC

NIC

Page 12: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

12

Linux kernel networking stack

Page 13: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

13

Linux kernel

Page 14: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

14

Команди - IP

ipcalc ip addr; ifconfig ip route; route ping; fping traceroute; mtr /etc/network/interfaces (Debian)

/etc/sysconfig/network-scripts (Redhat)

Page 15: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.
Page 16: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

ARP Protocol

RFC826: Ethernet Address Resolution Protocol: Or Converting Network Protocol Addresses to 48.bit Ethernet Address for Transmission on Ethernet Hardware. D. Plummer. November 1982. (Format: TXT=21556 bytes) (Also STD0037) (Status: STANDARD)

Page 17: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

Команди - ARP

ip neigh, arp arping

Page 18: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

ARP Table

gw:~# arp -n

Address HWtype HWaddress Flags Mask Iface

192.168.0.5 ether 00:0B:DB:4A:BD:8A C eth1

192.168.0.10 ether 00:0E:A6:6A:B1:12 C eth1

192.168.0.150 ether 00:14:BF:2C:94:5A C eth1

172.16.0.199 ether 00:13:02:4F:78:16 C eth1

192.168.0.124 ether 00:1C:BF:0F:24:F9 C eth1

172.16.0.22 (incomplete) eth1

85.14.21.165 ether 00:17:0F:AD:E1:C0 C eth0

85.14.21.44 ether 00:19:66:34:B1:24 CM eth0

Page 19: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

MAC address table

Switch# show mac-address-table vlan 254

. . .

vlan mac address type learn age ports

------+----------------+--------+-----+----------+-----------------

* 254 0004.6a00.326c dynamic Yes 5 Gi1/29

* 254 0003.f402.60e5 dynamic Yes 0 Gi1/3

* 254 0004.6a00.35c0 dynamic Yes 5 Gi1/3

* 254 0004.6a00.31dc dynamic Yes 5 Gi1/3

* 254 0040.c7f6.11e3 dynamic Yes 0 Gi1/3

* 254 0004.6a00.3004 dynamic Yes 5 Gi1/3

* 254 0004.6a00.350c dynamic Yes 5 Gi1/3

* 254 0004.6a00.3720 dynamic Yes 5 Gi1/3

. . .

Page 20: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

20

Sniffers

Wireshark, tshark

tcpdump

Page 21: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

21

Демонстрация

Page 22: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

22

Q&A

Page 23: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

23

TCP и UDP протоколи

UDP (RFC768 J.Postel 1980)– ports

TCP (RFC793 J.Postel 1981)– Session establishment and tear-down– Window procedure– Slow start and congestion avoidance (VJ 1988)

Berkeley sockets (1983)– The Berkeley socket API forms the de facto

standard abstraction for network sockets. Most other programing languages use an interface similar to the C API. // wikipedia

Page 24: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

24

Протоколи

1. baseband, *PSK, QAM-*, OFDM, CDMA, etc. overCat5, Fiber, HFC, phone line, RF etc.

2. Ethernet (802.3) , 802.11, 802.15, 802.16, PPP

3. IP/IPv6

4 and 5. TCP, UDP, RTP

7. HTTP, FTP, SMTP, POP3, IMAP4, SIP, XMPP, IRC, SNMP, SSH, TELNET, DNS, NTP, DHCP

Page 25: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

UDP header

0 7 8 15 16 23 24 31

+--------+--------+--------+--------+

| Source | Destination |

| Port | Port |

+--------+--------+--------+--------+

| | |

| Length | Checksum |

+--------+--------+--------+--------+

|

| data octets ...

+---------------- ...

User Datagram Header Format

Page 26: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

TCP Header

0 1 2 3

0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

| Source Port | Destination Port |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

| Sequence Number |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

| Acknowledgment Number |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

| Data | |U|A|P|R|S|F| |

| Offset| Reserved |R|C|S|S|Y|I| Window |

| | |G|K|H|T|N|N| |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

| Checksum | Urgent Pointer |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

| Options | Padding |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

| data |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

TCP Header Format

Page 27: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

27

Linux kernel networking stack

Page 28: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

28

TCP и UDP команди

telnet tcptraceroute netstat, fuser, lsof hping nc - TCP/IP swiss army knife

/etc/inetd.conf

Page 29: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

29

Q&A

Page 30: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

Extra slides

Page 31: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

iptables

Netfilter firewall

connection tracking

filter, nat, mangle, raw

Page 32: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

Linux router

ip route zebra/quagga XORP, Vyatta

Page 33: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

Linux bridge (switch)

brctl

ebtables

Page 34: Компютърни Мрежи и GNU/Linux Боян Кроснов boyan@krosnov.org  Мариян Маринов mm@yuhu.biz SiteGround LLC.

IP Fragmentation, MTU, PMTU-D

MTU concept TCP MSS DF (Don't Fragment) bit

ICMP type 3 (destination unreachable), code 4 (fragmentation needed but don't-fragment bit set)