云计算网络基础第八天
NAT :
? ? network address translation , 網絡地址轉換。
? -作用:
? ? ?將私有地址,轉換為公有地址,實現 Internet 的互訪。
? ? ??
?
? -場景:
? ? ? 企業網絡邊界;
?一般是在網關設備上實現 或者 防火墻;
?
? -類型:
? ? ? 靜態NAT
? ? ? 公有地址與私有地址 是 1:1?
?動態NAT
? ?傳統動態NAT - 1:1 ;?
PAT/PNAT/Port-NAT ,即基于端口的NAT,端口復用/IP復用
? ? ? ? ?也就是,使用公網的IP地址+端口號的形式,
?來區分內網的不同私有IP地址主機;
? ?NAT條目舉例(PAT):
? 12.1.1.1:X ---- 192.168.Y.Y:x
?
? -配置:
?R1:
? ? ip nat inside source static 192.168.1.1 ?12.1.1.1?
show ip nat translation ?// 查看 NAT 轉換條目?
debug ip nat // 查看 數據包的 NAT 轉換過程(現網不能開)
undebug all // 關閉設備上的所有的 debug?
? -測試:
? ? ?PC-1?
? ? ? ? ping 100.1.1.1 ?
??
真實設備上如下:
? ?ip nat inside source static 192.168.1.1 ?12.1.1.1?
? ?ip nat inside source static 192.168.1.2 ?12.1.1.3
? ?
? ?以上寫法,在真實的設備上,是不存在的 - 第二條命令無法輸入
----------------------------------------------------- ?
PAT 配置思路:
? ?前提條件:
? ? ? ?確保該路由器能夠去往外網,即得有路由。
??
? ?0、配置網關設備的inside 和 outside ?
? ? ? ? R1: ?
? ? ? ? ? ?interface gi0/1
? ? ? ? ? ? ? ? ip nat inside?
? ? ? ? ? ?interface ?gi0/0?
? ? ? ? ? ? ? ? ip nat outside ??
? ?1、首先通過 ACL ,匹配感興趣流量;
? ? ? ?access-list ?1 ?permit ?192.168.1.0 ?0.0.0.255?
? ?2、配置 PAT ;
? ? ? ip nat inside source list 1 ?interface gi0/0 ? ?
? ?3、驗證、調試與測試
? ? ? ?show ?ip ?access-list //查看ACL配置信息;
? show ?ip ?nat statistics ? // 查看 NAT 配置信息;?
? show ?ip ?nat ?translation ?// 查看NAT轉換表條目內容
? debug ?ip ?nat //實時顯示地址轉換過程(現網中不能用)
? PC-1 :
? ? ?ping 100.1.1.1
? PC-2 :
? ? ?ping 100.1.1.2?
? ? 4、關閉 debug 命令
? ? undebug all?
--------------------------------------
Router :
? ? 路由表
NAT表
-----------------------------------------------------
? inside(主動) ?-------> outside(被動) ,?
? ? ? ? ? 1、路由表
?2、NAT表
?
??
? inside(被動) ?<------- outside(主動) ,?
? ? ? ? ? 1、NAT表
?2、路由表
端口映射:
? ? ?
通常用于 ?外部網絡 ”主動“ 向內部網絡發起流量,
比如外部客戶,訪問公司的業務服務器;
或者,
在家的IT維護人員,實現對內部服務器的遠程管理。
R1:
? ?ip nat ?inside ?source ?static tcp 192.168.1.99 23?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?12.1.1.1 ?1919
?
? ?Test-pc :
? ? ?telnet ?12.1.1.1 ? ?1919?
? ? ? ? password : nihao?
? ? ?SW1>
-------------------------------------------------------
1、確保可以上網(PAT配置完好)
2、配置內網的交換機,開啟管理IP,并且配置遠程訪問密碼;
? ? ? SW1:
? ? interface vlan 1
? ?no shutdown
ip address 192.168.1.99 ?255.255.255.0?
ip default-gateway ?192.168.1.254
line vty 0 4?
? password nihao?
enable secret hehe
3、配置端口映射
? ? ? ? - 靜態 NAT?
? ?配置命令:
?ip nat ?inside ?source ?static tcp 192.168.1.99 23?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?12.1.1.1 ?1919
4、 測試:
? ? ? ?
? ? ? Test-PC : 100.1.1.1?
? ? ? ? ?telnet ?12.1.1.1 ? ?------> R1 ;?
? ? ? ? ?telnet ?12.1.1.1 ?1919 ---->SW1 ?
==============================
實驗需求:
讓在家做飯的 IT 男,能夠順利的使用自己的蘋果 ,遠程
訪問、控制 ?公司內網的 ? 服務器;
實驗步驟:
? ??
1、確保自己在家可以訪問公司的外網(IP)
2、確保公司內網主機可以與外網的設備進行互通;
? ? - 配置 PAT?
? ? # 定義感興趣流量
? ?access-list 1 permit ?192.168.1.0 ?0.0.0.255?
? ? # 配置轉換條目
? ? ? ?ip nat inside source list 1 ?gi0/0?
? ??
? ?此時,內網的主機,可以主動訪問外網設備,并且成功;
? ? 3、 在網關設備上配置”端口映射“:
? ? ?ip nat inside source static tcp ?192.168.1.99 23?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 12.1.1.1 ? 10090
? ? 4、配置內網的交換機的管理IP以及相關參數
? ? ?interface vlan 1
? ?no shutdown
ip address 192.168.1.99 ?255.255.255.0?
?ip default-gateway ?192.168.1.254?
? ?
?line vty 0 4?
? ? password ?nihao?
?
?enable ?password ?HAHAHAHA
轉載于:https://blog.51cto.com/13513556/2048417
總結
以上是生活随笔為你收集整理的云计算网络基础第八天的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: EMF+GEF的属性页问题
- 下一篇: Math.random()