第九周
1、總結(jié)ip分類以及每個(gè)分類可以分配的IP數(shù)量
IP地址由兩部分組成
- 網(wǎng)絡(luò)ID:標(biāo)識(shí)網(wǎng)絡(luò)暮芭,每個(gè)網(wǎng)段分配一個(gè)網(wǎng)絡(luò)ID朴肺,處于高位
- 主機(jī) ID:標(biāo)識(shí)單個(gè)主機(jī)黔牵,由組織分配給各設(shè)備留攒,處于低位
類型 | 網(wǎng)絡(luò)ID位數(shù) | 網(wǎng)絡(luò)數(shù) | 每個(gè)網(wǎng)絡(luò)中的主機(jī)數(shù) | |
---|---|---|---|---|
A類 | 8(最高一位0開頭) | 126=2^7 | 2^24-2=16777214 | |
B類 | 16(最高二位10開頭) | 2^14=16384 | 2^16-2=65534 | |
C類 | 24(最高三位110開頭) | 2^21=2097152 | 2^8-2=254 |
2煤惩、總結(jié)IP配置方法
使用掩碼將IP地址分成,網(wǎng)絡(luò)ID和主機(jī)ID稼跳。
劃分子網(wǎng):將一個(gè)大的網(wǎng)絡(luò)(主機(jī)數(shù)多)劃分成多個(gè)小的網(wǎng)絡(luò)(主機(jī)數(shù)少)盟庞,主機(jī)ID位數(shù)變少吃沪,網(wǎng)絡(luò)ID位數(shù)變多汤善,網(wǎng)絡(luò)ID位向主機(jī)ID位借位
合并超網(wǎng):將多個(gè)小網(wǎng)絡(luò)合并成一個(gè)大網(wǎng),主機(jī)ID位向網(wǎng)絡(luò)ID位借位
3、使用nmcli實(shí)現(xiàn)bonding
共7種模式:0-6 Mode红淡,主要使用Mod1 不狮,和Mode4.
- 第?種模式:Mode=1,即: (active-backup) Active-backup policy(主-備份策略)
特點(diǎn):只有?個(gè)設(shè)備處于活動(dòng)狀態(tài)在旱,當(dāng)?個(gè)宕掉另?個(gè)?上由備份轉(zhuǎn)換為主設(shè)備摇零。mac地址是外部可?得,從外?看來(lái)桶蝎,bond的MAC地址是唯?的驻仅,以避免switch(交換機(jī))發(fā)?混亂。此模式只提供了容錯(cuò)能?登渣;由此可?此算法的優(yōu)點(diǎn)是可以提供??絡(luò)連接的可?性噪服,但是它的資源利?率較低,只有?個(gè)接?處于?作狀態(tài)胜茧,在有 N 個(gè)?絡(luò)接?的情況下粘优,資源利?率為1/N。 - 第五種模式:mod=4呻顽,即:(802.3ad) IEEE 802.3adDynamic link aggregation(IEEE 802.3ad 動(dòng)態(tài)鏈接聚合)
特點(diǎn):創(chuàng)建?個(gè)聚合組雹顺,它們共享同樣的速率和雙?設(shè)定。根據(jù)802.3ad規(guī)范將多個(gè)slave?作在同?個(gè)激活的聚合體下廊遍。
必要條件:
條件1:ethtool?持獲取每個(gè)slave的速率和雙?設(shè)定嬉愧。
條件2:switch(交換機(jī))?持IEEE 802.3ad Dynamic link aggregation。
條件3:?多數(shù)switch(交換機(jī))需要經(jīng)過(guò)特定配置才能?持802.3ad模式喉前。
mode4需要交換機(jī)支持英染,下面以Mode=1做演示。
#新增加兩塊網(wǎng)卡eth1和eth2被饿,將這兩塊網(wǎng)卡做綁定
NAME UUID TYPE DEVICE
eth0 fed95e28-f18c-4d8c-8f33-cdad1c41eb48 ethernet eth0
Wired connection 1 6b9ef669-fa55-350e-9d77-e6796abddfae ethernet eth1
Wired connection 2 d6631399-4c3b-3b62-9706-280623374e99 ethernet eth2
# 添加一個(gè)bond接口為bond0
nmcli connection add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup,miimon=1000"
root@centos8 ~]$nmcli device status
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected eth0
eth1 ethernet connected Wired connection 1
eth2 ethernet connected Wired connection 2
bond0 bond connecting (getting IP configuration) bond0
lo loopback unmanaged
#給bond0添加接口
[root@centos8 ~]$nmcli connection add type ethernet slave-type bond con-name bond0-port1 ifname eth1 master bond0
Connection 'bond0-port1' (09b090c2-7952-434a-ae19-d2305ab5db69) successfully added.
[root@centos8 ~]$nmcli connection add type ethernet slave-type bond con-name bond0-port2 ifname eth2 master bond0
Connection 'bond0-port2' (961f2fd4-66f4-4343-95c3-6a42bfe9149a) successfully added.
#給bond0 添加ip地址四康,網(wǎng)關(guān),dns
[root@centos8 ~]$nmcli connection modify bond0 ipv4.addresses '192.168.1.48' ipv4.gateway 192.168.1.252 ipv4.dns 223.5.5.5
# 激活connection:
[root@centos8 ~]$nmcli connection up bond0-port1
[root@centos8 ~]$nmcli connection up bond0-port2
[root@centos8 ~]$nmcli connection up bond0
#使bond0開機(jī)有效
[root@centos8 ~]$nmcli connection modify bond0 connection.autoconnect-slaves 1
# 再次激活connection:
[root@centos8 ~]$nmcli connection up bond0
# 驗(yàn)證
[root@centos8 ~]$nmcli connection show
NAME UUID TYPE DEVICE
eth0 fed95e28-f18c-4d8c-8f33-cdad1c41eb48 ethernet eth0
bond0 33380509-8f1e-4747-8a8a-f13caa786b7b bond bond0
bond0-port1 09b090c2-7952-434a-ae19-d2305ab5db69 ethernet eth1
bond0-port2 961f2fd4-66f4-4343-95c3-6a42bfe9149a ethernet eth2
bond0 6c059a6a-9cde-4ced-a13e-78fd7c69655d bond --
bond0 7d8a2468-754e-4dbb-80b6-73fef65bbfaf bond --
Wired connection 1 6b9ef669-fa55-350e-9d77-e6796abddfae ethernet --
Wired connection 2 d6631399-4c3b-3b62-9706-280623374e99 ethernet --
[root@centos8 ~]$cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:93:21:27
Slave queue ID: 0
Slave Interface: eth2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:93:21:31
Slave queue ID: 0
[root@centos8 ~]$