Wednesday, August 6, 2008

[Cisco] ip nat outside source

[PC]<----------[R1]-----------------[R2]

PC = 192.168.2.2/24, no default gateway

[R2]
int lo0
ip add 20.0.0.1 255.255.255.255
int f0/0
ip add 192.168.1.2 255.255.255.0
ip route 10.0.0.1 255.255.255.0 192.168.1.1

[R1]
int f0/0
ip add 192.168.1.1 255.255.255.0
ip nat outside
int f0/1
ip add 192.168.2.1 255.255.255.0
ip nat inside
ip nat inside source static 192.168.2.2 10.0.0.1
ip nat outside source static 20.0.0.1 192.168.2.100 add-route <<<
ip route 0.0.0.0 0.0.0.0 192.168.1.2
ip route 20.0.0.0 255.255.255.0 192.168.1.2 <<<

#sh ip route
20.0.0.0/24 is subnetted, 1 subnets
S 20.0.0.0 [1/0] via 192.168.1.2
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
S 192.168.1.10/32 [1/0] via 20.0.0.1
C 192.168.1.0/24 is directly connected, FastEthernet0/0
192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
S 192.168.2.10/32 [1/0] via 20.0.0.1
C 192.168.2.0/24 is directly connected, FastEthernet0/1
S* 0.0.0.0/0 [1/0] via 192.168.1.2
#sh ip nat tran
Pro Inside global Inside local Outside local Outside global
--- --- --- 192.168.2.10 20.0.0.1
--- 10.0.0.1 192.168.2.2 --- ---

[R2]
R2#ping 10.0.0.1 source lo0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.0.1, timeout is 2 seconds:
Packet sent with a source address of 20.0.0.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/15/28 ms