有時候,我在使用ensp動手做實驗時在想,ensp裡的網絡設備能不能正常訪問互聯網呢?這樣就可以更加真實的模擬環境。經過一番折騰,終於實現了。今天把這個案例分享給大家。
藉助VMware虛擬機的NAT網卡,實現上網
安裝完VMware虛擬機之後,電腦會多出現兩張網卡,一張是VMnet1,一張是VMnet8。其中VMnet1是橋接模式,VMnet8是NAT模式。
eNSP綁定本地網卡,與仿真設備進行通信
eNSP工具中的雲代表通過各種網絡技術連接起來的計算機網絡環境,目前可實現的功能包括:仿真設備之間建立映射關係、綁定網卡與仿真設備之間進行通信,以及通過開放UDP端口方式與外部程序進行通信。
1、向工作區中添加“雲”,雙擊“雲”圖標,打開“雲”配置界面。
2、在“端口創建”區域框中,依據連接至雲的設備接口類型選擇相應的“端口類型”,這裡選擇“VMnet8”的網卡。
前期的工作已完成,下面通過一個小案例,把知識點串聯起來。
網絡拓撲
拓撲中使用一臺USG6000、終端PC1和一個已綁定VMnet8的雲。其中雲的配置請參考上文。
終端PC1配置如下:
防火牆上配置:
配置G1/0/1接口IP地址,其實G1/0/1的IP就是終端PC1的網關地址。
<code>[USG6000V1] interface GigabitEthernet1/0/1 [USG6000V1-GigabitEthernet1/0/1] ip address 192.168.1.254 255.255.255.0/<code>
配置G1/0/0接口自動獲取IP地址,從VMnet8中自動獲取地址。
<code>[USG6000V1]dhcp enable#全局模式使能dhcp服務 [USG6000V1] interface GigabitEthernet1/0/0 [USG6000V1-GigabitEthernet1/0/0]ip address dhcp-alloc/<code>
配置安全區域zone,把對應的接口加入到對應的zone中
<code>[USG6000V1]firewall zone trust [USG6000V1-zone-trust]add interface GigabitEthernet 1/0/1 #把接口G1/0/1加入到trust中 [USG6000V1]firewall zone untrust [USG6000V1-zone-trust]add interface GigabitEthernet 1/0/0 #把接口G1/0/0加入到untrust中/<code>
配置安全策略,放通local安全區域到untrust區域的策略,用於測試防火牆是否正正常上外網。
<code>[USG6000V1]security-policy [USG6000V1-policy-security]rule name 10 [USG6000V1-policy-security-rule-10] source-zone local [USG6000V1-policy-security-rule-10] destination-zone untrust [USG6000V1-policy-security-rule-10] action permit/<code>
此時,防火牆就可以正常的訪問到互聯網了,驗證如下:
讓終端PC1上外網,就變得相當簡單了,可以採用nat的模式,使其上外網。
NAT配置步驟
1、配置NAT地址池,這個地址池要和G1/0/0接口的IP地址在同一網段。
<code>[USG6000V1]nat address-group address_1 [USG6000V1-address-group-address_1] section 0 192.168.224.142 192.168.224.143/<code>
2、配置NAT策略
<code>[USG6000V1]nat-policy [USG6000V1-policy-nat]rule name to_Internet [USG6000V1-policy-nat-rule-to_Internet]source-zone trust [USG6000V1-policy-nat-rule-to_Internet]destination-zone untrust [USG6000V1-policy-nat-rule-to_Internet]action source-nat address-group address_1/<code>
3、配置安全策略
<code>[USG6000V1]security-policy [USG6000V1-policy-security]rule name 20 [USG6000V1-policy-security-rule-20] source-zone trust [USG6000V1-policy-security-rule-20] destination-zone untrust [USG6000V1-policy-security-rule-20] action permit/<code>
到此,終端PC1就可以通過NAT去訪問互聯網了。驗證如下
我們還可以查看防火牆的會話表項的,如下圖