05.02 網絡route命令實踐案例

第一章 查看確認三臺主機默認路由配置條目信息

服務器01主機路由表條目信息:

[root@oldboy ~]# route -n
Kernel IP routing table
Destination     Gateway     Genmask     Flags   Metric  Ref     Use Iface
10.0.0.0            0.0.0.0     255.255.255.0   U       0       0       0   eth0
169.254.0.0     0.0.0.0     255.255.0.0     U       1002    0       0   eth0
0.0.0.0         10.0.0.254  0.0.0.0         UG      0       0       0   eth0

服務器02主機路由表條目信息:

[root@oldboy ~]# route -n
Kernel IP routing table
Destination     Gateway     Genmask     Flags   Metric  Ref     Use Iface
10.0.0.0            0.0.0.0     255.255.255.0   U       0       0       0   eth0
10.0.1.0            0.0.0.0     255.255.255.0   U       0       0       0   eth1
169.254.0.0     0.0.0.0     255.255.0.0     U       1002    0       0   eth0
169.254.0.0     0.0.0.0     255.255.0.0         U       1003    0       0   eth1

服務器03主機路由表條目信息:

[root@oldboy ~]# route -n
Kernel IP routing table
Destination     Gateway     Genmask     Flags   Metric  Ref     Use Iface
10.0.1.0            0.0.0.0     255.255.255.0   U       0       0       0   eth0
169.254.0.0     0.0.0.0     255.255.0.0     U       1002    0       0   eth0
0.0.0.0         10.0.1.254  0.0.0.0         UG      0       0       0   eth0

第二章 服務器主機配置網路路由條目信息

服務器01上配置網路路由條目:

[root@oldboy ~]# route add -net 10.0.1.0 netmask 255.255.255.0 gw 10.0.0.11
[root@oldboy ~]# route -n
Kernel IP routing table
Destination     Gateway     Genmask     Flags   Metric  Ref     Use Iface
10.0.0.0            0.0.0.0     255.255.255.0   U       0       0       0   eth0
10.0.1.0            10.0.0.11   255.255.255.0   UG      0       0       0   eth0
169.254.0.0     0.0.0.0     255.255.0.0     U       1002    0       0   eth0
0.0.0.0         10.0.0.254  0.0.0.0         UG      0       0       0   eth0
說明:利用添加網絡路由條目命令,已經在服務器01上正確添加上一條去往10.0.1.0網段路由條目

服務器03上配置網絡路由條目:

服務器03上配置網絡路由條目:
[root@oldboy ~]# route add -net 10.0.0.0 netmask 255.255.255.0 gw 10.0.1.11
[root@oldboy ~]# route -n
Kernel IP routing table
Destination     Gateway     Genmask     Flags   Metric  Ref     Use Iface
10.0.0.0            10.0.1.11   255.255.255.0   UG      0       0       0   eth0
10.0.1.0            0.0.0.0     255.255.255.0   U       0       0       0   eth0
169.254.0.0     0.0.0.0     255.255.0.0     U       1002    0       0   eth0
0.0.0.0         10.0.1.254  0.0.0.0         UG      0       0       0   eth0
說明:利用添加網絡路由條目命令,已經在服務器03上正確添加上一條去往10.0.0.0網段路由條目

第三章 配置開啓主機路由轉發功能

服務器02主機在拓撲中負責進行路由轉發,需要開啓相應配置參數

服務器02主機在拓撲中負責進行路由轉發,需要開啓相應配置參數
[root@oldboy ~]# vim /etc/sysctl.conf 
net.ipv4.ip_forward = 1
[root@oldboy ~]# sysctl -p
net.ipv4.ip_forward = 1
...其餘顯示部分省略...
說明:默認數值爲0,將數值改爲1,路由轉發功能即表示開啓

第四章 虛擬主機路由訪問驗證

服務器01主機上進行驗證:

[root@oldboy ~]# traceroute 10.0.1.10
traceroute to 10.0.1.10 (10.0.1.10), 30 hops max, 60 byte packets
 1  10.0.0.11 (10.0.0.11)  0.247 ms  2.281 ms  2.245 ms
 2  10.0.1.10 (10.0.1.10)  3.077 ms !X  3.055 ms !X  3.018 ms !X
說明:通過traceroute路由路徑追蹤命令,已確認路由走向符合配置需求,即路由配置正確無誤。
     !X表示已經完成路由追蹤過程。

服務器03主機上進行驗證:

[root@oldboy ~]# traceroute 10.0.0.10
traceroute to 10.0.0.10 (10.0.0.10), 30 hops max, 60 byte packets
 1  10.0.1.11 (10.0.1.11)  0.295 ms  1.221 ms  1.175 ms
 2  10.0.0.10 (10.0.0.10)  1.797 ms !X  1.761 ms !X  1.727 ms !X
說明:通過traceroute路由路徑追蹤命令,已確認路由走向符合配置需求,即路由配置正確無誤。
     !X表示已經完成路由追蹤過程。

第五章 linux路由部署異常分析

防火牆異常問題:
服務器主機02起到路由轉發功能,類似於路由器的角色,因此服務器上防火牆功能需要關閉,否則防火牆相應條目會阻止掉路由轉發流量;具體iptables防火牆安全策略配置後續章節會進行講解,敬請期待!

虛擬網卡異常問題:
服務器主機網卡信息配置中,儘量選擇nat模式或者僅主機模式網卡進行配置,不要選擇LAN區段網卡配置方式,否則根據虛擬軟件網絡工作原理,LAN區段網卡配置模式無法進行路由的轉發,會影響最終配置效果。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章