Skip to content

Example: source address translation to interface

Alt text

r1

hostname r1
vrf def v1
 rd 1:1
 exit
int eth1
 vrf for v1
 ipv4 addr 1.1.1.1 255.255.255.252
 ipv6 addr 1234:1::1 ffff:ffff::
 exit

r2

hostname r2
vrf def v1
 rd 1:1
 exit
int eth1
 vrf for v1
 ipv4 addr 1.1.1.2 255.255.255.252
 ipv6 addr 1234:1::2 ffff:ffff::
 exit
int eth2
 vrf for v1
 ipv4 addr 1.1.1.5 255.255.255.252
 ipv6 addr 1234:2::1 ffff:ffff::
 exit
ipv4 route v1 8.8.8.8 255.255.255.255 1.1.1.6
ipv6 route v1 8888::8 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 1234:2::2
ipv4 nat v1 source 8.8.8.8 interface eth1
ipv6 nat v1 source 8888::8 interface eth1

r3

hostname r3
vrf def v1
 rd 1:1
 exit
int eth1
 vrf for v1
 ipv4 addr 1.1.1.6 255.255.255.252
 ipv6 addr 1234:2::2 ffff:ffff::
 exit
int lo1
 vrf for v1
 ipv4 addr 8.8.8.8 255.255.255.255
 ipv6 addr 8888::8 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
 exit
ipv4 route v1 0.0.0.0 0.0.0.0 1.1.1.5
ipv6 route v1 :: :: 1234:2::1
r3 tping 100 5 1.1.1.1 vrf v1 sou lo1
r3 tping 100 5 1234:1::1 vrf v1 sou lo1
r2 output show ipv4 nat v1 tran
r2 output show ipv6 nat v1 tran
  1. Install ContainerLab as described here
  2. Fetch crypt-nat03 file
  3. Launch ContainerLab crypt-nat03.yml topology:

   containerlab deploy --topo crypt-nat03.yml  
4. Destroy ContainerLab crypt-nat03.yml topology:

   containerlab destroy --topo crypt-nat03.yml  
5. Copy-paste configuration for each node in the lab topology

  1. Fetch or compile freeRtr rtr.jar file.
    You can grab it here
  2. Fetch crypt-nat03.tst file here
  3. Launch crypt-nat03.tst test:

   java -jar ../../rtr.jar test tester crypt-nat03 path ./ temp ./ wait
4. Destroy freeRtr crypt-nat03.tst test:

   Ctrl-C (In freeRtr test window)