1. 程式人生 > >學習筆記(第5天)

學習筆記(第5天)

學習筆記(由老師筆記自己整理)


第五天學習

ARP
MAC :物理地址,全球範圍內,唯一的指定一個物理設備;
確定通信設備/終端, 一定要 IP 地址與 MAC 地址結合; 即,必須形成IP地址與MAC地址的對應關系,如下: IP --- MAC
對應關系的形成方式:
手動 -
自動 - ARP
分類 - ARP
代理ARP
ARP病毒

無故ARP

R1 ----- R2 ---- R3

R1 : ping 192.168.23.3
源IP - 192.168.12.1
目標IP - 192.168.23.3
問題: 不通 ;
定位:路由;
定義:什麽是路由?如何實現?
不同網段之間的設備互通,稱之為路由;
通過 具有路由功能的設備來實現:
路由器
多層交換機
本質:
路由表;

路由器的工作過程:
僅僅關註數據包的”目標IP地址“
然後將其與路由表中的路由條目進行”匹配“
匹配成功,則轉發;
不成功,則丟棄;

條目匹配舉例:
數據包 - 192.168.12.1 ----> 192.168.23.3

查看路由表 --- R1# show ip route

C 192.168.12.0 /24 is directly gi0/0

手動添加去往目標IP地址所需要的路由:
R1(config)# ip route 192.168.23.0 255.255.255.0
192.168.12.2

R1# show ip route
S 192.168.23.0 /24 [1/0] via , 192.168.12.2
C 192.168.12.0 /24 is directly gi0/0

路由 與 ARP 關系:
1、首先通過路由,確定數據轉發方向;
2、其次獲得具體目標IP對應的物理地址;即 ARP ;

------------------------------------------------------
Router 作為 DHCP 服務器:

1、配置 Router 地址:
Router(config)#hostname GateWay
GateWay(config)#interface gi0/0
GateWay(config-if)# no shutdown
GateWay(config-if)# ip address 192.168.1.1 255.255.255.0

2、啟動 DHCP 服務 :
  GateWay(config)# service dhcp

3、配置 DHCP 地址池:
GateWay(config)# ip dhcp pool CCIE
GateWay(dhcp-config)# network 192.168.1.0 255.255.255.0
GateWay(dhcp-config)# default-router 192.168.1.254
GateWay(dhcp-config)# dns-server 8.8.8.8
4、配置 DHCP 客戶端 :
點擊 - ”DHCP“ ;

5、驗證命令:
在服務器端的驗證命令:
GateWay# show ip dhcp binding
GateWay# show running-config
在客戶端的驗證:
運行--> cmd ---> ipconfig /all


6、特殊地址處理:
內網有業務服務器,編址如下:
web - 192.168.1.20 /24
email - 192.168.1.75 /24
FTP - 192.168.1.88 /24
OA - 192.168.1.166 /24
DHCP 地址排除:
GateWay(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.10

註意:
low 地址與 high 地址不同,則表示一段連續的IP;
如果相同,則表示”排除一個地址“;
---------------------------------------------------------
Switch 作為 DHCP 服務器:

1、配置交換機的IP地址;
Switch(config)# interface vlan 1
Switch(config-if)# no shutdown
Switch(config-if)# ip address 192.168.1.250 255.255.255.0
2、啟動 DHCP 服務 :
Switch(config)# service dhcp
3、配置 DHCP 的排除地址:
Switch(config)# ip dhcp excluded-address 192.168.1.1
192.168.1.20
4、配置 DHCP 地址池 :
  Switch(config)# ip dhcp pool CCNP
Switch(dhcp-config)# network 192.168.1.0 255.255.255.0
Switch(dhcp-config)# default-router 192.168.1.1
Switch(dhcp-config)# dns-server 8.8.8.8
5、配置 DHCP 客戶端 ;
6、驗證:
Switch#show ip interface brief // 查看交換機接口IP地址配置;
Switch#show running-config //查看 DHCP 的相關配置命令;
Switch#show ip dhcp binding //查看DHCP服務器分配成功的IP地址

在 PC 上 :
ipconfig /all // 在 PC 的命令行中查看自動獲取的IP地址
ping x.x.x.x // 在 PC1 上 測試與 PC2 的 連通性;


---------------------------------------------------------

需求:
確保醫院中的財務部、門診部、藥房 ,屬於不同的網段;
每個部門的主機,自動獲取IP地址;
網段分別為:
財務部 - 192.168.1.0 / 24 ;
192.168.1.254 (網關)
8.8.8.8 (DNS-server)
門診部 - 192.168.2.0 / 24 ;
192.168.2.254 (網關)
7.7.7.7 (DNS-server)
藥房 - 192.168.3.0 / 24 ;
192.168.3.254 (網關)
9.9.9.9 (DNS-server)
確保部門內部和部門之間的主機都可以互相 Ping 通 ;

路由器配置命令:
Router(config)#interface gi0/0 // 財務部網關接口;
Router(config-if)# no shutdown
Router(config-if)# ip address 192.168.1.254 255.255.255.0
Router(config-if)#description GW-CaiWu

Router(config)#interface gi0/0 // 門診部網關接口;
Router(config-if)# no shutdown
Router(config-if)# ip address 192.168.2.254 255.255.255.0
Router(config-if)#description GW-MenZhen

Router(config)#interface gi0/0 // 藥房網關接口;
Router(config-if)# no shutdown
Router(config-if)# ip address 192.168.3.254 255.255.255.0
Router(config-if)#description GW-YaoFang


該項目出於成本控制方面的考慮,建議節省3臺服務器,將
交換機作為 DHCP server :

SW1(config)#interface vlan 1
SW1(config-if)#no shutdown
SW1(config-if)#ip address 192.168.1.250 255.255.255.0

SW1(config)# ip dhcp pool CaiWu
SW1(dhcp-config)# network 192.168.1.0 255.255.255.0
SW1(dhcp-config)# default-router 192.168.1.254
SW1(dhcp-config)# dns-server 8.8.8.8
SW1(dhcp-config)# exit
SW1(config)# service dhcp


SW2(config)#interface vlan 1
SW2(config-if)#no shutdown
SW2(config-if)#ip address 192.168.2.250 255.255.255.0

SW2(config)# ip dhcp pool MenZhen
SW2(dhcp-config)# network 192.168.2.0 255.255.255.0
SW2(dhcp-config)# default-router 192.168.2.254
SW2(dhcp-config)# dns-server 7.7.7.7
SW2(dhcp-config)# exit
SW2(config)# service dhcp


SW3(config)#interface vlan 1
SW3(config-if)#no shutdown
SW3(config-if)#ip address 192.168.3.250 255.255.255.0

SW3(config)# ip dhcp pool MenZhen
SW3(dhcp-config)# network 192.168.3.0 255.255.255.0
SW3(dhcp-config)# default-router 192.168.3.254
SW3(dhcp-config)# dns-server 9.9.9.9
SW3(dhcp-config)# exit
SW3(config)# service dhcp


-------------------------------------------------------
DHCP Relay 配置:(僅在門診樓與藥房的網關端口進行配置)
將路由器 配置為 DHCP relay , 需要在每個部門的
網關端口上進行配置 -
Router(config)# interface gi0/2
Router(config-if)# description GW-YaoFang
Router(config-if)# ip helper-address 192.168.1.250
// 此時該網關端口接收到 DHCP discover
報文以後,會將廣播報文,以單播的方式
發送到該 DHCP 服務器 - 192.168.1.250 ;
並且源地址為 192.168.3.254 ,
目標地址為 192.168.1.250 ,
Router(config)# service dhcp // 作為DHCP中繼,必須要開啟DHCP;
註意:
當 DHCP 服務器上具有多個 DHCP 地址池時,
服務器是通過 DHCP 報文 中的源IP地址來進行地址池區分的;
在 DHCP relay 環境中,本質上就是根據每個部門的網關IP地址
來決定的;
-----------------------------------------------------
在 DHCP 服務器 上,配置三個網關的 DHCP 地址池;
同時,在 DHCP 服務器上配置 ”網關IP“地址 :
確保 DHCP 服務器能夠回應其他部門/網段的
DHCP 客戶端發送的 DHCP 報文;

------------------------------------------------------------

浮動靜態路由回顧:
作用 -
實現鏈路備份;
當主鏈路活動的時候,針對主鏈路的路由,進入路由表;
主鏈路故障以後,
備份鏈路針對的路由(管理距離大於1的),進入路由表;
主鏈路修復以後,管理距離為 1 的路由,會再次進入路由
表,之前針對備份鏈路的路由,被排擠出路由表。
因為,在路由表中,針對一個目標網絡,只能是存在
一個最好的,比較原則:
首先比較 AD ,值越小越好;
如果AD相同,則比較 Metric,值越小越好;

此處的備份鏈路的路由,是通過調整 AD 值來實現的;

浮動路由/備份路由 的 配置命令:
Router(config)# ip route 192.168.50.0 255.255.255.0 192.168.23.3 200
驗證命令
show ip route
show ip route 192.168.50.0
該命令查看的是一個具體的路由條目的詳細信息:
例如:
R1#show ip route 192.168.50.0
Routing entry for 192.168.50.0/24
Known via "static", distance 1, metric 0
Routing Descriptor Blocks:
* 192.168.12.2
Route metric is 0, traffic share count is 1

學習筆記(第5天)