将互联网连接到终端设备的 NAT 问题

网络工程 思科 路由 纳特 互联网
2022-02-15 15:03:55

所以,在这个(看似)永无止境的我开车三个小时失败的传奇中,我遇到了另一个问题。我在山的一侧有一个路由器和一个交换机,我需要连接到互联网,以及大约五个依赖于该互联网连接的终端设备。我能够从路由器 ping 互联网 (google.com8.8.8.8),但我无法从我的交换机或连接到该交换机的终端设备 ping 互联网。

我能够从终端设备 ping 路由器的公共和私有地址,但我无法 ping 过去的任何东西。我对路由器和交换机的运行配置如下。

路由器运行配置(路由器为Cisco 1900):

Connected.
!
ip domain name aftonradio.com
ip cef
no ipv6 cef
multilink bundle-name authenticated
!
cts logging verbose
!
crypto pki trustpoint TP-self-signed-338930330
 enrollment selfsigned
 subject-name cn=IOS-Self-Signed-Certificate-338930330
 revocation-check none
 rsakeypair TP-self-signed-338930330
!
!
crypto pki certificate chain TP-self-signed-
    <!-- OMITTED -->
license udi pid CISCO1921/K9 sn FGL192424AJ
!
!
username <!-- OMITTED -->
!
redundancy
!
!
ip ssh time-out 60
ip ssh authentication-retries 5
!
!
!
!
interface Embedded-Service-Engine0/0
 no ip address
 shutdown
!
interface GigabitEthernet0/0
 ip address <!-- Public address -->
 ip nat outside
 ip virtual-reassembly in
 duplex full
 speed auto
!
interface GigabitEthernet0/1
 ip address 192.168.2.1 255.255.255.0
 ip nat inside
 ip virtual-reassembly in
 duplex full
 speed auto
!
ip forward-protocol nd
!
ip http server
ip http access-class 23
ip http authentication local
ip http secure-server
ip http timeout-policy idle 60 life 86400 requests 10000
!
ip nat pool NATPOOL 192.168.2.1 192.168.2.11 prefix-length 24
ip nat inside source list 1 pool NATPOOL
ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/0
!
!
!
access-list 1 permit 192.168.2.0 0.0.0.255
!
!
!
control-plane
!
!
banner motd ^C BE VERY CAREFUL IN HERE! UNAUTHORIZED ACCESS PROHIBITED!!! ^C
!
<!-- OUTPUT OMITTED -->
!
scheduler allocate 20000 1000
!
end

交换机运行配置(交换机为300系列):

config-file-header
AftonSwitch
v1.4.2.4 / R800_NIK_1_4_194_194
CLI v1.0
set system mode switch

file SSD indicator encrypted
@
ssd-control-start
ssd config
ssd file passphrase control unrestricted
no ssd file integrity control
ssd-control-end cb0a3fdb1f3a1af4e4430033719968c0
!
voice vlan oui-table add 0001e3 Siemens_AG_phone________
voice vlan oui-table add 00036b Cisco_phone_____________
voice vlan oui-table add 00096e Avaya___________________
voice vlan oui-table add 000fe2 H3C_Aolynk______________
voice vlan oui-table add 0060b9 Philips_and_NEC_AG_phone
voice vlan oui-table add 00d01e Pingtel_phone___________
voice vlan oui-table add 00e075 Polycom/Veritel_phone___
voice vlan oui-table add 00e0bb 3Com_phone______________
hostname AftonSwitch
line ssh
password 84670ba1e3259880245906ea38214cd08c0c9df9 encrypted
exit
<!-- OUTPUT OMITTED -->
ip ssh port 22
ip ssh server
ip ssh password-auth
ip ssh pubkey-auth auto-login
!
interface vlan 1
 ip address 192.168.2.2 255.255.255.0
 no ip address dhcp
!
interface gigabitethernet1
 description Router
 switchport mode access
!
interface gigabitethernet2
 description Transmitter
 switchport mode access
!
interface gigabitethernet3
 description Raspberry_Pi
 switchport mode access
!
interface gigabitethernet4
 description New_Nautel_Transmitter
 switchport mode access
!
interface gigabitethernet5
 shutdown
 switchport mode access
!
interface gigabitethernet6
 shutdown
 switchport mode access
!
interface gigabitethernet7
 shutdown
 switchport mode access
!
interface gigabitethernet8
 shutdown
 switchport mode access
!
interface gigabitethernet9
 shutdown
 switchport mode access
!
interface gigabitethernet10
 description Management_Interface
 switchport mode access
!
exit
ip default-gateway 192.168.2.1

根据我在这里阅读的所有内容,我们做了我们需要做的一切,以便将 Internet 连接分配到终端设备。我错过了什么?

1个回答

您似乎正在尝试混合 NAT 实现。

试试这个地址.2.11虽然我不建议允许交换机访问公共互联网)。:

no ip nat pool NATPOOL 192.168.2.1 192.168.2.11 prefix-length 24
!
ip nat inside source list 1 interface GigabitEthernet0/0 overload
!
no access-list 1 permit 192.168.2.0 0.0.0.255
!
access-list 1 permit 192.168.2.2 0.0.0.0
access-list 1 permit 192.168.2.3 0.0.0.0
access-list 1 permit 192.168.2.4 0.0.0.0
access-list 1 permit 192.168.2.5 0.0.0.0
access-list 1 permit 192.168.2.6 0.0.0.0
access-list 1 permit 192.168.2.7 0.0.0.0
access-list 1 permit 192.168.2.8 0.0.0.0
access-list 1 permit 192.168.2.9 0.0.0.0
access-list 1 permit 192.168.2.10 0.0.0.0
access-list 1 permit 192.168.2.11 0.0.0.0
!

您也不应该路由到接口,而是路由到下一个跃点地址:

no ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/0
!
ip route 0.0.0.0 0.0.0.0 <next hop ISP address>
!