Login

Navigation

This articles is published 871 days ago and last updated 370 days ago, some information may be out of date.

Cisco Router Connect to the Internet

Cover_2021-11-08_104518.png

前言:
思科路由器的基礎網絡設定,所有的練習建基於模擬器(EVE-NG)。
目錄內容:

啟用及設定埠口的「IP」地址
在這次的範例中 interface Ethernet0/0LAN埠口,interface Ethernet0/1WAN埠口。

2021-11-08_095949.png

Router#enable                  
Router#
Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#
Router(config)#interface e0/1
Router(config-if)#ip address 19.86.11.96 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#
Router(config)#interface e0/0
Router(config-if)#ip address 17.16.1.1 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#end

查看埠口的IP地址

2021-11-08_100025.png

Router#show ip interface brief
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 17.16.1.1 YES manual up up
Ethernet0/1 19.86.11.96 YES manual up up

配置「DHCP」伺服器
每個連接Internet的裝置都需要分配唯一的IP位址。DHCP使網路管理員能從中心結點監視和分配IP位址。當某台電腦移到網路中的其它位置時,能自動收到新的IP位址。From Wiki

2021-11-08_100227.png

Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#
Router(config)#ip dhcp excl
Router(config)#ip dhcp excluded-address 17.16.1.1 17.16.1.50
Router(config)#
Router(config)#ip dhcp pool LAN
Router(dhcp-config)#network 17.16.1.0 255.255.255.0
Router(dhcp-config)#defa
Router(dhcp-config)#default-router 17.16.1.1
Router(dhcp-config)#dns-server 1.1.1.1
Router(dhcp-config)#end

客戶端電腦測試:

2021-11-08_102824.png

2021-11-08_102850.png

「NAT(Network Address Translation)」位址轉換
簡單理解為內網所有裝置共用1粒外網IP地址,是一種在IP封包通過路由器防火牆時重寫來源IP地址或目的IP位址的技術。from: Wiki

2021-11-08_101952.png

Router#enable 
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int e0/0
Router(config-if)#ip nat inside
Router(config-if)#exit
Router(config)#int e0/1
Router(config-if)#ip nat outside
Router(config-if)#exit
Router(config)#
Router(config)#
Router(config)#access-list 1 permit 17.16.1.0 0.0.0.255
Router(config)#
Router(config)#ip nat inside source list 1 interface ethernet 0/1 overload
Router(config)#end

「Route」路由配置
預設路由,任何沒有匹配的路由封包,最後會經預設路由(19.86.11.1)傳送到網外。

2021-11-08_102115 - Route.png

Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#
Router(config)#ip route 0.0.0.0 0.0.0.0 19.86.11.1
Router(config)#end

連接Internet測試:

2021-11-08_103014.png

「Port-Forwarding」端口轉發
就是透過外網IP地址19.86.11.96的不同端口連線到內網服務,今次範例中以遠程桌面的3389端口接入到內網IP地址為17.16.1.51的電腦(Windows7)
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#
Router(config)#ip nat inside source static tcp 17.16.1.51 3389 19.86.11.96 3389
Router(config)#exit

連線測試:

2021-11-08_103600.png

2021-11-08_103611.png

2021-11-08_103648.png

最後記得「存檔」所有設定

2021-11-08_102115 - Save.png

Router#write memory
Building configuration...
[OK]
結語:
與家用路由器比較,Cisco的路由器設定上較為煩瑣,因為家用路由器已經預設了WANLAN(bridge) 但Cisco的路由器基於商用,每個設定步驟對網絡的知識會有更深入了解。

站內相關貼文: