1. 程式人生 > >如何把私有地址轉換成公有地址來訪問外部?

如何把私有地址轉換成公有地址來訪問外部?

bcd size color blog sum ide 默認 1.0 col

技術分享圖片
操作步驟及思路:
一.分別給pc1,pc2配上ip地址,子網掩碼,網關
#pc1
ip:192.168.1.1
子網掩碼:255.255.255.0
網關:192.168.1.254
pc2
ip:192.168.1.2
子網掩碼:255.255.255.0
網關:192.168.1.254
二.在路由1上配置網關
interface g0/0
no shutdown //激活端口
ip address 192.168.1.254 255.255.255.0
interface g0/1
ip address 10.1.1.1 255.255.255.0
三.在路由2上配置ip
interface g0/0
no shutdown //激活端口
ip address 10.1.1.2 255.255.255.0
interface g0/1
no shutdown //激活端口
ip address 192.168.20.1.1.1
四.在路由3上配置ip
interface g0/0
no shutdown //激活端口
ip address 20.1.1.2 255.255.255.0
五.在路由1中設置默認路由讓它能發包過去
ip routing //開啟路由功能
ip route 0.0.0.0 0.0.0.0 10.1.1.2
六.讓其他兩個路由器自己學習
路由2:
route rip //啟用rip路由協議
version 2 //使用rip2版本
no auto-summary //關閉rip協議動態匯總
network 10.1.1.0
network 20.1.1.0 進入rip協議
路由3:
route rip //啟用rip路由協議
version 2 //使用rip2版本
no auto-summary //關閉rip協議動態匯總
network 20.1.1.0 進入rip協議
七.在路由1把私有地址轉化為公有地址
interface g0/0
ip nat inside //內網邊界
interface g0/1
ip nat outside //外網邊界
access-list 1 permit 192.168.1.0 0.0.0.255
確定要進行nat轉換的私有地址空間
ip nat inside source list 1 interface g0/1
針對私有地址配置對應mat轉換條目
八.在pc機上驗證
ping 20.1.1.2 拼外網看能成功否

如何把私有地址轉換成公有地址來訪問外部?