1. 程式人生 > >視頻學習記錄和規劃day08

視頻學習記錄和規劃day08

考試題目 記錄 應用層 網絡 模型

規劃:
2017-4-24 周一 第5章前2h
2017-4-25 周二 第5章中2h
2017-4-26周三 第5章 後2h tcp三次握手和子網劃分等
2017-4-27周四 第6章 2h
2017-4-28周五 第6-7閉卷考試 錄屏 以及第7章考試題目講解
周六 早會!

2017-4-24 21:00-
網絡:




應用層:ftp(20用於傳輸數據,21用於傳輸控制信息)、telnet(23)、smtp(25)、http(80)、pop3(110)










20has在公司畫的 網絡七層模型理解記憶圖 at 2017-4-26 16:30
2017-4-24 19:17-
TCP三次握手過程:



20has在家裏畫的 網絡七層模型理解記憶圖 at 2017-4-26 20:30


握手狀態:

揮手狀態:
http://blog.csdn.net/lianghe_work/article/details/46458889 參考網址講解


20has在家裏畫的 TCP三次握手和四次揮手以及11種狀態小結 at 2017-5-3 20:37






用戶訪問網站的原理


2017-4-27 22:18-
dig 查看解析
nslookup 查看對應的域名和ip
host
ping


hostname 臨時生效(重啟失效)
vim /etc/sysconfig/network 重啟後生效
vim /etc/hosts ipv4和ipv6的行尾也要修改下主機名

setup也可以修改主機名

route -n 查看網關
netstat -rn 查看網關

啟用虛擬網卡, 臨時生效 重啟失效
停用虛擬網卡 ifconfig eth0:1 down 或者ifconfig eth0:1 192.168.140.138/24 down
ip addr del 192.168.140.138 dev eth0

查看網絡狀態:
ifconfig
ip
route -n
hostname(uname -n)
netstat

[[email protected] ~]# lsof -i :22 #方法一
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 1170 root 3u IPv4 11273 0t0 TCP *:ssh (LISTEN)
sshd 1170 root 4u IPv6 11281 0t0 TCP *:ssh (LISTEN)
sshd 1293 root 3r IPv4 12007 0t0 TCP 192.168.140.137:ssh->192.168.140.1:50500 (ESTABLISHED)

netstat -lntup|grep 22 #方法二


[[email protected] ~]# lsof |grep ESTABLISHED #查看活動的進程
sshd 1293 root 3r IPv4 11984 0t0 TCP 192.168.140.137:ssh->192.168.140.1:49631 (ESTABLISHED)

[[email protected] ~]# ping -c3 -i2 -s512 www.baidu.com #c次數 i間隔 s發包大小
PING www.a.shifen.com (14.215.177.37) 512(540) bytes of data.
520 bytes from 14.215.177.37: icmp_seq=1 ttl=128 time=7.78 ms
520 bytes from 14.215.177.37: icmp_seq=2 ttl=128 time=7.56 ms
520 bytes from 14.215.177.37: icmp_seq=3 ttl=128 time=8.12 ms

--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 4014ms
rtt min/avg/max/mdev = 7.566/7.825/8.124/0.229 ms


tcpdump -n icmp -i eth0 #抓包eth0的icmp協議

第6-7關課後考核題講解:
[[email protected] ~]# tcpdump port 22 -Stn -c 3
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
IP 192.168.140.137.ssh > 192.168.140.1.49631: Flags [P.], seq 1684696282:1684696490, ack 1439315332, win 317, length 208
IP 192.168.140.1.49631 > 192.168.140.137.ssh: Flags [.], ack 1684696490, win 255, length 0
IP 192.168.140.137.ssh > 192.168.140.1.49631: Flags [P.], seq 1684696490:1684696666, ack 1439315332, win 317, length 176
3 packets captured
3 packets received by filter
0 packets dropped by kernel

[[email protected] ~]# netstat -tl #查看tcp和listen狀態的網絡鏈接
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 localhost:smtp *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 localhost:smtp *:* LISTEN




1、在最開始,客戶端和服務器都處於CLOSED狀態
2、服務器會創建socket開始監聽,服務器狀態LISTEN
3、客戶端向服務器發送隨機數SYN,請求簡歷連接,發完後自己狀態變為SYN_CENT
4、服務器收到客戶端發來的SYN,然後回復ACK=SYN+1和新的隨機數SYN,發完後自己變為SYN_RCVD
5、客戶端收到服務器發送來的SYN和ACK後馬上回復ACK=SYN+1,回復完後狀態變為ESTABLISHED
6、服務端在收到客戶端發來的ACK後直接進入ESTABLISHED
至此,三次握手完成,連接建立!

tcpdump host 10.10.0.10 and port 80





視頻學習記錄和規劃day08