{"id":226,"date":"2020-05-08T11:28:36","date_gmt":"2020-05-08T16:28:36","guid":{"rendered":"http:\/\/blog.miguelsarmiento.com\/?p=226"},"modified":"2020-05-09T12:21:52","modified_gmt":"2020-05-09T17:21:52","slug":"nat64-lab-using-ciscos-asr-and-dns64-maybe","status":"publish","type":"post","link":"https:\/\/blog.miguelsarmiento.com\/?p=226","title":{"rendered":"NAT64 Lab Using Cisco&#8217;s ASR and DNS64 (Maybe)."},"content":{"rendered":"<p>Hello again,<\/p>\n<p>The other day I came across a configuration by Cisco in regard to NAT64.<\/p>\n<p>As you are aware, NAT64 permits IPv6 only networks to access IPv4 networks and vice versa.<\/p>\n<p>Of course, they are not entirely IPv6 only networks since they probably have an IPv4 gateway somewhere allowing them to access IPv4 networks on the Internet.<\/p>\n<p><span style=\"font-size: 1.0625rem; letter-spacing: 0px;\">I decided to do the lab and test it using <a href=\"https:\/\/www.eve-ng.net\/\" target=\"_blank\" rel=\"noopener noreferrer\">EVE-NG<\/a>.<\/span><!--more--><\/p>\n<h1>Setup<\/h1>\n<p>The <a href=\"https:\/\/community.cisco.com\/t5\/networking-documents\/ipv6-stateful-nat64-configuration-example\/ta-p\/3124475\" target=\"_blank\" rel=\"noopener noreferrer\">original lab<\/a> is part of the Cisco forums.<\/p>\n<p>I added dynamic mapping and where a DNS64 server will fit in the topology.<\/p>\n<p>Since I did not want to configure a DNS64 server (it can be done of course), I also added a\u00a0way of showing how DNS64 manipulates IPv4 addresses into IPv6 addresses.<\/p>\n<p>Figure 1. has the topology in use.<\/p>\n<figure id=\"attachment_229\" aria-describedby=\"caption-attachment-229\" style=\"width: 1218px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blog.miguelsarmiento.com\/wp-content\/uploads\/2020\/05\/NAT64.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-229 size-full\" src=\"https:\/\/blog.miguelsarmiento.com\/wp-content\/uploads\/2020\/05\/NAT64.png\" alt=\"\" width=\"1218\" height=\"465\" srcset=\"https:\/\/blog.miguelsarmiento.com\/wp-content\/uploads\/2020\/05\/NAT64.png 1218w, https:\/\/blog.miguelsarmiento.com\/wp-content\/uploads\/2020\/05\/NAT64-300x115.png 300w, https:\/\/blog.miguelsarmiento.com\/wp-content\/uploads\/2020\/05\/NAT64-768x293.png 768w, https:\/\/blog.miguelsarmiento.com\/wp-content\/uploads\/2020\/05\/NAT64-1024x391.png 1024w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><figcaption id=\"caption-attachment-229\" class=\"wp-caption-text\"><center>Figure 1. Lab Topology.<\/center><\/figcaption><\/figure>\n<p>The lab uses the EVE-NG virtual environment.<\/p>\n<p>It has the following devices:<\/p>\n<ul>\n<li>A CSR router 1000 V 16.07.0.1.<\/li>\n<li>A 3725 router acting as the IPv6 gateway only to the IPv6 network.<\/li>\n<li>A 3725 router acting as the IPv4 gateway.<\/li>\n<li>Another 3725 mimicking as an Internet device.<\/li>\n<li>A DNS server using BIND.<\/li>\n<\/ul>\n<p>In this scenario, the CSR router is the NAT64 with two networks terminating on it. The CSR uses the native implementation of NAT64 on it.<\/p>\n<p>As usual, I will only show the relevant parts.<\/p>\n<h1>Configurations<\/h1>\n<h2>NAT64<\/h2>\n<pre>hostname CSR-100v-R2\r\n!\r\nipv6 unicast-routing \r\n!\r\ninterface Loopback0\r\n no ip address\r\n ipv6 address BB10::1\/128\r\n!\r\ninterface Loopback1\r\n ip address 2.2.2.2 255.255.255.255\r\n!\r\ninterface GigabitEthernet1\r\n no ip address\r\n negotiation auto\r\n nat64 enable\r\n ipv6 address 2001::A00:B\/128\r\n ipv6 rip RIP enable\r\n ipv6 rip RIP default-information only\r\n no mop enabled\r\n no mop sysid\r\n!\r\ninterface GigabitEthernet2\r\n ip address 10.0.0.2 255.255.255.0\r\n negotiation auto\r\n nat64 enable\r\n no mop enabled\r\n no mop sysid\r\n!\r\ninterface GigabitEthernet3\r\n no ip address\r\n shutdown\r\n negotiation auto\r\n no mop enabled\r\n no mop sysid\r\n!\r\ninterface GigabitEthernet4\r\n no ip address\r\n shutdown\r\n negotiation auto\r\n no mop enabled\r\n no mop sysid\r\n!\r\nrouter ospf 1\r\n network 2.2.2.2 0.0.0.0 area 1\r\n network 10.0.0.0 0.0.0.255 area 0\r\n!\r\nip forward-protocol nd\r\nip http server\r\nip http authentication local\r\nip http secure-server\r\nip route 0.0.0.0 0.0.0.0 10.0.0.1\r\n!\r\nipv6 router rip RIP\r\n!\r\nipv6 access-list nat64-acl\r\n permit ipv6 host 2001::A00:A any\r\n!\r\ncontrol-plane\r\n!\r\nnat64 prefix stateful 3001::\/96\r\nnat64 v4 pool POOL1 10.0.0.5 10.0.0.15\r\nnat64 v6v4 static 2001::A00:C 10.0.0.16\r\nnat64 v6v4 list nat64-acl pool POOL1\r\n\r\n<\/pre>\n<h2>IPV6 Only<\/h2>\n<pre>hostname IPV6-Only-R1\r\n!\r\nipv6 unicast-routing\r\nipv6 cef\r\n!\r\ninterface Loopback0\r\n no ip address\r\n ipv6 address AB00::1\/128\r\n ipv6 rip RIP enable\r\n!\r\ninterface Loopback1\r\n no ip address\r\n ipv6 address AB01::1\/128\r\n ipv6 rip RIP enable\r\n!\r\ninterface Loopback2\r\n no ip address\r\n ipv6 address 2001::A00:C\/128\r\n ipv6 rip RIP enable\r\n! \r\ninterface FastEthernet0\/0\r\n no ip address\r\n duplex auto\r\n speed auto\r\n ipv6 address 2001::A00:A\/128\r\n ipv6 rip RIP enable\r\n!\r\ninterface FastEthernet0\/1\r\n no ip address\r\n shutdown\r\n duplex auto\r\n speed auto\r\n!\r\nip forward-protocol nd\r\n!\r\n!\r\nip http server\r\nno ip http secure-server\r\n!\r\nipv6 router rip RIP<\/pre>\n<h2>IPv4 Only<\/h2>\n<pre>hostname IPV4_ONLY_R3\r\n!\r\nip cef\r\n!\r\nno ip domain lookup\r\nipv6 unicast-routing\r\nipv6 cef\r\n!\r\n!\r\nip ssh version 1\r\n!\r\ninterface Loopback0\r\n ip address 1.1.1.1 255.255.255.255\r\n!\r\ninterface Loopback1\r\n ip address 1.1.1.2 255.255.255.255\r\n!\r\ninterface FastEthernet0\/0\r\n ip address 10.0.0.1 255.255.255.0\r\n duplex auto\r\n speed auto\r\n!\r\ninterface FastEthernet0\/1\r\n ip address 10.10.1.1 255.255.255.0\r\n duplex auto\r\n speed auto\r\n!\r\nrouter ospf 1\r\n log-adjacency-changes\r\n network 1.1.1.1 0.0.0.0 area 1\r\n network 1.1.1.2 0.0.0.0 area 0\r\n network 10.0.0.0 0.0.0.255 area 0\r\n!<\/pre>\n<h2>WAN<\/h2>\n<pre>hostname WAN\r\n!\r\nboot-start-marker\r\nboot-end-marker\r\n!\r\nenable password cisco\r\n!\r\nno aaa new-model\r\nmemory-size iomem 5\r\nip cef\r\n!\r\nip domain name test.com\r\n! \r\nmultilink bundle-name authenticated\r\nusername cisco password 0 cisco\r\narchive\r\n log config\r\n hidekeys\r\n! \r\n!\r\ninterface FastEthernet0\/0\r\n ip address 10.10.1.2 255.255.255.0\r\n duplex auto\r\n speed auto\r\n!\r\ninterface FastEthernet0\/1\r\n no ip address\r\n shutdown\r\n duplex auto\r\n speed auto\r\n!\r\nip forward-protocol nd\r\nip route 10.0.0.0 255.0.0.0 10.10.1.1\r\n!<\/pre>\n<h1>TESTING<\/h1>\n<p>Now that we have the lab setup, let&#8217;s test connectivity.<\/p>\n<p>A point to make, the original Cisco setup used a static mapping. While this is fine, a better scenario is to test by using also a dynamic mapping. In this fashion,\u00a0 you could have several IPv6 addresses map to an IPv4 network.<\/p>\n<p>The mappings could be one-to-one, one-to-many, or many-to-one since NAT64 is just another way of doing NAT.<\/p>\n<p>On R2 (NAT64) issue:<\/p>\n<pre>CSR-100v-R2#sh nat64 mappings static\r\n\r\nStatic mappings configured: 1\r\n\r\nDirection Protocol Address (Port, if any)\r\n Non-key Address (Port, if any)\r\n RG ID Mapping ID Is Valid\r\nv6v4 --- 2001::A00:C\r\n\r\n 10.0.0.16\r\n 0 0 FALSE<\/pre>\n<p>The output above shows that a static mapping is in place.\u00a0 IPv4 address 10.0.0.16 maps to IPv6 address 2001::A00:C.<\/p>\n<p>You should be able to ping 10.0.0.16 from R3.<\/p>\n<pre>IPV4_ONLY_R3#ping 10.0.0.16\r\n\r\nType escape sequence to abort.\r\nSending 5, 100-byte ICMP Echos to 10.0.0.16, timeout is 2 seconds:\r\n!!!!!\r\nSuccess rate is 100 percent (5\/5), round-trip min\/avg\/max = 12\/14\/20 ms<\/pre>\n<p>On R2 issue the following:<\/p>\n<pre>CSR-100v-R2#sh nat64 translations\r\n\r\nProto Original IPv4 Translated IPv4\r\n Translated IPv6 Original IPv6 \r\n----------------------------------------------------------------------------\r\n\r\nillegal --- --- \r\n 10.0.0.16 2001::a00:c\r\n\r\nTotal number of translations: 1<\/pre>\n<p>As you can see the NAT64 now has a translation for\u00a02001::A00:C, allowing you to connect to it.<\/p>\n<p>You may ask what IPv6 address is used to connect? R3 does not have an IPv6.<\/p>\n<p>Issue the command debug IP ICMP on R3 and debug IPv6 ICMP on R1.<\/p>\n<p>Now on R3 ping 10.0.0.16:<\/p>\n<pre>IPV4_ONLY_R3#ping 10.0.0.16\r\n\r\nType escape sequence to abort.\r\nSending 5, 100-byte ICMP Echos to 10.0.0.16, timeout is 2 seconds:\r\n!!!!!\r\nSuccess rate is 100 percent (5\/5), round-trip min\/avg\/max = 20\/22\/28 ms\r\nIPV4_ONLY_R3#\r\nIPV4_ONLY_R3#\r\nIPV4_ONLY_R3#\r\n*Mar 1 03:24:02.875: ICMP: echo reply rcvd, src 10.0.0.16, dst 10.0.0.1\r\n*Mar 1 03:24:02.899: ICMP: echo reply rcvd, src 10.0.0.16, dst 10.0.0.1\r\n*Mar 1 03:24:02.919: ICMP: echo reply rcvd, src 10.0.0.16, dst 10.0.0.1\r\n*Mar 1 03:24:02.943: ICMP: echo reply rcvd, src 10.0.0.16, dst 10.0.0.1\r\n*Mar 1 03:24:02.963: ICMP: echo reply rcvd, src 10.0.0.16, dst 10.0.0.1<\/pre>\n<p>On R1 you will see:<\/p>\n<pre>IPV6-Only-R1#\r\n*Mar 1 01:43:08.035: ICMPv6: Received echo request from 3001::A00:1\r\n*Mar 1 01:43:08.035: ICMPv6: Sending echo reply to 3001::A00:1\r\n*Mar 1 01:43:08.115: ICMPv6: Received echo request from 3001::A00:1\r\n*Mar 1 01:43:08.115: ICMPv6: Sending echo reply to 3001::A00:1\r\n*Mar 1 01:43:08.191: ICMPv6: Received echo request from 3001::A00:1\r\n*Mar 1 01:43:08.191: ICMPv6: Sending echo reply to 3001::A00:1\r\n*Mar 1 01:43:08.263: ICMPv6: Received echo request from 3001::A00:1\r\n*Mar 1 01:43:08.263: ICMPv6: Sending echo reply to 3001::A00:1\r\n*Mar 1 01:43:08.335: ICMPv6: Received echo request from 3001::A00:1\r\n*Mar 1 01:43:08.335: ICMPv6: Sending echo reply to 3001::A00:1\r\n*Mar 1 01:43:54.479: ICMPv6: Received ICMPv6 packet from FE80::5201:FF:FE02:0, type 134<\/pre>\n<p>As you can see, when R3 pings 10.0.0.16\u00a0 the packet changes first using the prefix 3001::1 configured on the NAT64 device. In turn, the\u00a0 NAT64 device redirects the packet with the new source and pings the original destination.<\/p>\n<p>Now let&#8217;s take a look at dynamic mapping.<\/p>\n<pre>CSR-100v-R2#show NAT64 mappings dynamic\r\n\r\nDynamic mappings configured: 1\r\n\r\nDirection ID ACL\r\n Pool Flags\r\n RG ID Mapping ID\r\n\r\nv6v4 4 nat64-acl \r\n POOL1 0x00000000 (none)\r\n 0 0\r\n\r\nThis shows you that a dynamic mapping is configured using an access list and POOL1.\r\n\r\nCSR-100v-R2#sh ipv6 access-list \r\nIPv6 access list nat64-acl\r\n permit ipv6 host 2001::A00:A any sequence 10\r\n\r\nCSR-100v-R2#sh nat64 pools \r\n\r\nPools configured: 1\r\n\r\nProtocol HSL ID Name\r\n Is Single Range\r\n Ranges\r\n\r\nIPv4 4 POOL1\r\n TRUE (10.0.0.5 - 10.0.0.15)\r\n 10.0.0.5 - 10.0.0.15<\/pre>\n<p>Thus, the IPv6 address on R1 is mapped to a pool of addresses (10.0.0.5-10).<\/p>\n<p>Of course, the discerning reader would have noticed that the pool is defined for an\u00a0 \/128 address. Yes, you should have at least a network of the same size as the one you are trying to map.<\/p>\n<p>How do you access an IPV4 address then?<\/p>\n<p>R1 tries to connect to 10.10.1.2 using the FSDN of the device.\u00a0 It sends a DNS query to the DNS64 server. The DNS server gets an A record as the response of the query. The DNS64 server then converts it to an IPV4.<\/p>\n<p>It uses 3001::10.10.1.2\u00a0 or 3001::A0A:102 then it sends the record to R1. R1 then connects using that IPv6 address.<\/p>\n<p>The NAT64 device is configured to use the 3001:: for NAT64 conversions, strips the 3001:: part converts the remainder address A0A:102 to 10.10.1.2, and sends the packet.<\/p>\n<p>It also adds a translation using the pool defined. In this case, NAT64 connects to WAN using 10.0.0.6 (2001::A00:A) as the source address.<\/p>\n<pre>IPV6-Only-R1#ping 3001::A0A:102\r\n\r\nType escape sequence to abort.\r\nSending 5, 100-byte ICMP Echos to 3001::A0A:102, timeout is 2 seconds:\r\n!!!!!\r\nSuccess rate is 100 percent (5\/5), round-trip min\/avg\/max = 44\/52\/64 ms<\/pre>\n<p>A DNS64 server will do this conversion automatically if the FQDN resolves only to an A record.<\/p>\n<p>To simulate this conversion, on R2 issue:<\/p>\n<pre>CSR-100v-R2#ping 3001::10.10.1.2\r\nType escape sequence to abort.\r\nSending 5, 100-byte ICMP Echos to 3001::A0A:102, timeout is 2 seconds:\r\n.....\r\nSuccess rate is 0 percent (0\/5)<\/pre>\n<p>Notice that R2 tried to connect using 3001::A0A:102 which would be the IPv6 address that the DNS64 server would have been given to R1 as a result of the DNS query. Remember the DNS64 server is configured with the same prefix as the NAT64 server will use for NAT64 translations.<\/p>\n<p>This connection is bidirectional. On R3 ping 10.0.0.6, you would get:<\/p>\n<pre>IPV4_ONLY_R3#ping 10.0.0.6\r\n\r\nType escape sequence to abort.\r\nSending 5, 100-byte ICMP Echos to 10.0.0.6, timeout is 2 seconds:\r\n!!!!!\r\nSuccess rate is 100 percent (5\/5), round-trip min\/avg\/max = 8\/19\/56 ms<\/pre>\n<p>This is not surprising at all since R2 is announcing 10.0.0.6 as the source IP address (as any NAT device would regardless).<\/p>\n<h1>REMARKS<\/h1>\n<p>If you look through the configuration, you will notice that R1 uses IPv6 RIP and R3 uses IPv4 OSPF.<\/p>\n<p>The reason is so no static routing is configured explicitly.<\/p>\n<p>On the IPv6 side, RIP is announcing a default route. You do not have to use RIP any other IGP that supports IPv6 would do.<\/p>\n<p>OSPF on the IPv4 side advertises the 10.0.0.0 network.<\/p>\n<p>We also have a default IPv4 route to the Internet on R2, since the WAN router by definition does not take part in any dynamic routing.<\/p>\n<h1>CONCLUSIONS<\/h1>\n<p>The setup of NAT64 was not as complicated as I thought it would be.<\/p>\n<p>As usual, Cisco is very\u00a0thorough in its documentation. I was able to dig deep into the different commands to configure pools and observe bidirectional communications.<\/p>\n<p>In a real implementation, you will need a few things:<\/p>\n<ul>\n<li>A functional DNS64 server configured accordingly.<\/li>\n<li>Your IPv4 router should be a firewall of some sort so you can properly do your static translations to the Internet in addition to your IPv6 network.<\/li>\n<li>Above also means that you will be doing double NAT.<\/li>\n<li>Finally, your IPv6 servers will need a one-to-one translation to the internal IPv4 address you plan to use if those servers need to be accessed from IPv4 only networks.<\/li>\n<li>Above is probably the\u00a0trickiest part of this since the IPv6 to IPv4 part seems to be straight forward.<\/li>\n<\/ul>\n<p>I hope you enjoy the lab.<\/p>\n<p>Until we meet again.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello again, The other day I came across a configuration by Cisco in regard to NAT64. As you are aware, NAT64 permits IPv6 only networks to access IPv4 networks and vice versa. Of course, they are not entirely IPv6 only networks since they probably have an IPv4 gateway somewhere allowing them to access IPv4 networks &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.miguelsarmiento.com\/?p=226\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;NAT64 Lab Using Cisco&#8217;s ASR and DNS64 (Maybe).&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-226","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=\/wp\/v2\/posts\/226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=226"}],"version-history":[{"count":46,"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=\/wp\/v2\/posts\/226\/revisions"}],"predecessor-version":[{"id":267,"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=\/wp\/v2\/posts\/226\/revisions\/267"}],"wp:attachment":[{"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.miguelsarmiento.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}