网络基础知识

1、简述osi七层模型和TCP/IP五层模型
1).osi七层模型

OSI模型把网络通信的工作分为7层,分别是物理层、数据链路层、网络层、传输层、会话层、表示层和应用层。每一层对于上一层来讲是透明的,上层只需要使用下层提供的接口,并不关心下层是如何实现的。

2).TCP/IP五层模型

TCP/IP模型把网络通信的工作分为5(或4)层,分别是物理层、数据链路层(如果是四层模型数据链路层和物理层在一层)、网络层、传输层、应用层。每一层都呼叫它的下一层提供的网络来完成自己的需求。

2、总结描述TCP三次握手四次挥手

以S表示server端,以C表示client端

1).建立TCP连接:三次握手协议

C:S你在吗?有个小问题请教你,OVER;

S:我在呢,能听清吗?知无不言,OVER;

C:能听清,OVER

········································

balabalabalabalabalabalabalabala········

········································

2).关闭TCP连接:四次握手协议

C:我说完了,谢谢你的解答,OVER;

S:收到,有一些事情还需要向你交代

········································

balabalabalabalabalabalabalabala········

········································

S:我说完了,OVER;

C:收到,我会等一会(两个最大报文生命周期),如果你没有收到我的会话,请在告诉我,OVER

(S收到确认,会话结束)

3、描述TCP和UDP区别
UDP TCP
是否连接 无连接 面向连接
是否可靠 不可靠传输,不使用流量控制和拥塞控制 可靠传输,使用流量控制和拥塞控制
连接对象个数 支持一对一,一对多,多对一和多对多交互通信 只能是一对一通信
传输方式 面向报文 面向字节流
首部开销 首部开销小,仅8字节 首部最小20字节,最大60字节
适用场景 适用于实时应用(IP电话、视频会议、直播等) 适用于要求可靠传输的应用,例如文件传输
4、网卡绑定bond0的实现

实验环境为Ubuntu18.04
查看网卡

gw@node2:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:dc:64:01 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:dc:64:0b brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:dc:64:15 brd ff:ff:ff:ff:ff:ff
    inet 192.0.2.129/24 brd 192.0.2.255 scope global dynamic noprefixroute eth2
       valid_lft 1766sec preferred_lft 1766sec
    inet 192.0.2.99/24 brd 192.0.2.255 scope global secondary noprefixroute eth2
       valid_lft forever preferred_lft forever
    inet6 fe80::1c67:1e7a:bf5:dc15/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

选择eth0和eth1两块网卡做bond0

gw@node2:~$ sudo nmcli connection add type bond con-name bond0 ifname bond0 autoconnect yes mode balance-rr
Connection 'bond0' (25626852-cdea-4826-9558-8ad1074647e1) successfully added.
gw@node2:~$ sudo nmcli connection add type bond-slave ifname eth0 master bond0
Connection 'bond-slave-eth0' (fae60b5a-4492-4f4d-8dfc-ad45d85680e1) successfully added.
gw@node2:~$ sudo nmcli connection add type bond-slave ifname eth1 master bond0
Connection 'bond-slave-eth1' (69307142-0c78-4f1c-8e85-9c61e7c6e78f) successfully added.
gw@node2:~$ nmcli connection show
NAME             UUID                                  TYPE      DEVICE
bond-slave-eth0  fae60b5a-4492-4f4d-8dfc-ad45d85680e1  ethernet  eth0
bond-slave-eth1  69307142-0c78-4f1c-8e85-9c61e7c6e78f  ethernet  eth1
bond0            25626852-cdea-4826-9558-8ad1074647e1  bond      bond0
eth2             6e598b7b-888e-44e2-b441-8c4ac5ce5c89  ethernet  eth2
gw@node2:~$ sudo nmcli connection modify bond0 ipv4.addresses 192.0.2.100/24 ipv4.gateway 192.0.2.1 ipv4.method manual
gw@node2:~$ sudo nmcli connection reload
gw@node2:~$ sudo nmcli connection up bond0
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/18)
gw@node2:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP group default qlen 1000
    link/ether 00:0c:29:dc:64:01 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP group default qlen 1000
    link/ether 00:0c:29:dc:64:01 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:dc:64:15 brd ff:ff:ff:ff:ff:ff
    inet 192.0.2.129/24 brd 192.0.2.255 scope global dynamic noprefixroute eth2
       valid_lft 1562sec preferred_lft 1562sec
    inet 192.0.2.99/24 brd 192.0.2.255 scope global secondary noprefixroute eth2
       valid_lft forever preferred_lft forever
    inet6 fe80::1c67:1e7a:bf5:dc15/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
6: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:dc:64:01 brd ff:ff:ff:ff:ff:ff
    inet 192.0.2.100/24 brd 192.0.2.255 scope global noprefixroute bond0
       valid_lft forever preferred_lft forever
    inet6 fe80::ff15:9380:3289:f4e1/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
上一篇:Linux组网简单配置


下一篇:MySQL Orchestrator自动导换+VIP切换