2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
20 #include <snat/nat64.h>
21 #include <snat/snat.h>
22 #include <vnet/fib/fib_table.h>
25 nat64_add_del_pool_addr_command_fn (vlib_main_t * vm,
26 unformat_input_t * input,
27 vlib_cli_command_t * cmd)
29 nat64_main_t *nm = &nat64_main;
30 unformat_input_t _line_input, *line_input = &_line_input;
31 ip4_address_t start_addr, end_addr, this_addr;
32 u32 start_host_order, end_host_order;
36 clib_error_t *error = 0;
39 return clib_error_return (0,
40 "NAT64 disabled, multi thread not supported");
42 /* Get a line of input. */
43 if (!unformat_user (input, unformat_line_input, line_input))
46 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
48 if (unformat (line_input, "%U - %U",
49 unformat_ip4_address, &start_addr,
50 unformat_ip4_address, &end_addr))
52 else if (unformat (line_input, "tenant-vrf %u", &vrf_id))
54 else if (unformat (line_input, "%U", unformat_ip4_address, &start_addr))
55 end_addr = start_addr;
56 else if (unformat (line_input, "del"))
60 error = clib_error_return (0, "unknown input '%U'",
61 format_unformat_error, line_input);
66 start_host_order = clib_host_to_net_u32 (start_addr.as_u32);
67 end_host_order = clib_host_to_net_u32 (end_addr.as_u32);
69 if (end_host_order < start_host_order)
71 error = clib_error_return (0, "end address less than start address");
75 count = (end_host_order - start_host_order) + 1;
76 this_addr = start_addr;
78 for (i = 0; i < count; i++)
80 rv = nat64_add_del_pool_addr (&this_addr, vrf_id, is_add);
84 case VNET_API_ERROR_NO_SUCH_ENTRY:
86 clib_error_return (0, "NAT64 pool address %U not exist.",
87 format_ip4_address, &this_addr);
89 case VNET_API_ERROR_VALUE_EXIST:
91 clib_error_return (0, "NAT64 pool address %U exist.",
92 format_ip4_address, &this_addr);
98 increment_v4_address (&this_addr);
102 unformat_free (line_input);
108 nat64_cli_pool_walk (snat_address_t * ap, void *ctx)
110 vlib_main_t *vm = ctx;
112 if (ap->fib_index != ~0)
115 fib = fib_table_get (ap->fib_index, FIB_PROTOCOL_IP6);
118 vlib_cli_output (vm, " %U tenant VRF: %u", format_ip4_address,
119 &ap->addr, fib->ft_table_id);
122 vlib_cli_output (vm, " %U", format_ip4_address, &ap->addr);
127 static clib_error_t *
128 nat64_show_pool_command_fn (vlib_main_t * vm,
129 unformat_input_t * input,
130 vlib_cli_command_t * cmd)
132 nat64_main_t *nm = &nat64_main;
135 return clib_error_return (0,
136 "NAT64 disabled, multi thread not supported");
138 vlib_cli_output (vm, "NAT64 pool:");
139 nat64_pool_addr_walk (nat64_cli_pool_walk, vm);
144 static clib_error_t *
145 nat64_interface_feature_command_fn (vlib_main_t * vm,
147 input, vlib_cli_command_t * cmd)
149 nat64_main_t *nm = &nat64_main;
150 unformat_input_t _line_input, *line_input = &_line_input;
151 vnet_main_t *vnm = vnet_get_main ();
152 clib_error_t *error = 0;
154 u32 *inside_sw_if_indices = 0;
155 u32 *outside_sw_if_indices = 0;
160 return clib_error_return (0,
161 "NAT64 disabled, multi thread not supported");
163 /* Get a line of input. */
164 if (!unformat_user (input, unformat_line_input, line_input))
167 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
169 if (unformat (line_input, "in %U", unformat_vnet_sw_interface,
171 vec_add1 (inside_sw_if_indices, sw_if_index);
172 else if (unformat (line_input, "out %U", unformat_vnet_sw_interface,
174 vec_add1 (outside_sw_if_indices, sw_if_index);
175 else if (unformat (line_input, "del"))
179 error = clib_error_return (0, "unknown input '%U'",
180 format_unformat_error, line_input);
185 if (vec_len (inside_sw_if_indices))
187 for (i = 0; i < vec_len (inside_sw_if_indices); i++)
189 sw_if_index = inside_sw_if_indices[i];
190 rv = nat64_add_del_interface (sw_if_index, 1, is_add);
193 case VNET_API_ERROR_NO_SUCH_ENTRY:
195 clib_error_return (0, "%U NAT64 feature not enabled.",
196 format_vnet_sw_interface_name, vnm,
197 vnet_get_sw_interface (vnm, sw_if_index));
199 case VNET_API_ERROR_VALUE_EXIST:
201 clib_error_return (0, "%U NAT64 feature already enabled.",
202 format_vnet_sw_interface_name, vnm,
203 vnet_get_sw_interface (vnm, sw_if_index));
205 case VNET_API_ERROR_INVALID_VALUE:
206 case VNET_API_ERROR_INVALID_VALUE_2:
208 clib_error_return (0,
209 "%U NAT64 feature enable/disable failed.",
210 format_vnet_sw_interface_name, vnm,
211 vnet_get_sw_interface (vnm, sw_if_index));
220 if (vec_len (outside_sw_if_indices))
222 for (i = 0; i < vec_len (outside_sw_if_indices); i++)
224 sw_if_index = outside_sw_if_indices[i];
225 rv = nat64_add_del_interface (sw_if_index, 0, is_add);
228 case VNET_API_ERROR_NO_SUCH_ENTRY:
230 clib_error_return (0, "%U NAT64 feature not enabled.",
231 format_vnet_sw_interface_name, vnm,
232 vnet_get_sw_interface (vnm, sw_if_index));
234 case VNET_API_ERROR_VALUE_EXIST:
236 clib_error_return (0, "%U NAT64 feature already enabled.",
237 format_vnet_sw_interface_name, vnm,
238 vnet_get_sw_interface (vnm, sw_if_index));
240 case VNET_API_ERROR_INVALID_VALUE:
241 case VNET_API_ERROR_INVALID_VALUE_2:
243 clib_error_return (0,
244 "%U NAT64 feature enable/disable failed.",
245 format_vnet_sw_interface_name, vnm,
246 vnet_get_sw_interface (vnm, sw_if_index));
256 unformat_free (line_input);
257 vec_free (inside_sw_if_indices);
258 vec_free (outside_sw_if_indices);
264 nat64_cli_interface_walk (snat_interface_t * i, void *ctx)
266 vlib_main_t *vm = ctx;
267 vnet_main_t *vnm = vnet_get_main ();
269 vlib_cli_output (vm, " %U %s", format_vnet_sw_interface_name, vnm,
270 vnet_get_sw_interface (vnm, i->sw_if_index),
271 i->is_inside ? "in" : "out");
275 static clib_error_t *
276 nat64_show_interfaces_command_fn (vlib_main_t * vm,
278 input, vlib_cli_command_t * cmd)
280 nat64_main_t *nm = &nat64_main;
283 return clib_error_return (0,
284 "NAT64 disabled, multi thread not supported");
286 vlib_cli_output (vm, "NAT64 interfaces:");
287 nat64_interfaces_walk (nat64_cli_interface_walk, vm);
292 static clib_error_t *
293 nat64_add_del_static_bib_command_fn (vlib_main_t *
296 * input, vlib_cli_command_t * cmd)
298 nat64_main_t *nm = &nat64_main;
299 unformat_input_t _line_input, *line_input = &_line_input;
300 clib_error_t *error = 0;
302 ip6_address_t in_addr;
303 ip4_address_t out_addr;
307 snat_protocol_t proto = 0;
312 return clib_error_return (0,
313 "NAT64 disabled, multi thread not supported");
315 if (!unformat_user (input, unformat_line_input, line_input))
318 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
320 if (unformat (line_input, "%U %u", unformat_ip6_address,
323 else if (unformat (line_input, "%U %u", unformat_ip4_address,
324 &out_addr, &out_port))
326 else if (unformat (line_input, "vrf %u", &vrf_id))
328 else if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
330 else if (unformat (line_input, "del"))
334 error = clib_error_return (0, "unknown input: '%U'",
335 format_unformat_error, line_input);
342 error = clib_error_return (0, "inside port and address must be set");
348 error = clib_error_return (0, "outside port and address must be set");
352 p = snat_proto_to_ip_proto (proto);
355 nat64_add_del_static_bib_entry (&in_addr, &out_addr, in_port, out_port, p,
360 case VNET_API_ERROR_NO_SUCH_ENTRY:
361 error = clib_error_return (0, "NAT64 BIB entry not exist.");
363 case VNET_API_ERROR_VALUE_EXIST:
364 error = clib_error_return (0, "NAT64 BIB entry exist.");
366 case VNET_API_ERROR_UNSPECIFIED:
367 error = clib_error_return (0, "Crerate NAT64 BIB entry failed.");
369 case VNET_API_ERROR_INVALID_VALUE:
371 clib_error_return (0, "Outside addres %U and port %u already in use.",
372 format_ip4_address, &out_addr, out_port);
379 unformat_free (line_input);
385 nat64_cli_bib_walk (nat64_db_bib_entry_t * bibe, void *ctx)
387 vlib_main_t *vm = ctx;
390 fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
394 vlib_cli_output (vm, " %U %u %U %u %U vrf %u %s %u sessions",
395 format_ip6_address, &bibe->in_addr,
396 clib_net_to_host_u16 (bibe->in_port), format_ip4_address,
397 &bibe->out_addr, clib_net_to_host_u16 (bibe->out_port),
398 format_snat_protocol, bibe->proto, fib->ft_table_id,
399 bibe->is_static ? "static" : "dynamic", bibe->ses_num);
403 static clib_error_t *
404 nat64_show_bib_command_fn (vlib_main_t * vm,
405 unformat_input_t * input, vlib_cli_command_t * cmd)
407 nat64_main_t *nm = &nat64_main;
408 unformat_input_t _line_input, *line_input = &_line_input;
409 clib_error_t *error = 0;
410 snat_protocol_t proto = 0;
413 return clib_error_return (0,
414 "NAT64 disabled, multi thread not supported");
416 if (!unformat_user (input, unformat_line_input, line_input))
419 if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
423 error = clib_error_return (0, "unknown input: '%U'",
424 format_unformat_error, line_input);
428 vlib_cli_output (vm, "NAT64 %U BIB:", format_snat_protocol, proto);
429 nat64_db_bib_walk (&nm->db, proto, nat64_cli_bib_walk, vm);
432 unformat_free (line_input);
437 static clib_error_t *
438 nat64_set_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input,
439 vlib_cli_command_t * cmd)
441 nat64_main_t *nm = &nat64_main;
442 unformat_input_t _line_input, *line_input = &_line_input;
443 clib_error_t *error = 0;
444 u32 timeout, tcp_trans, tcp_est, tcp_incoming_syn;
446 tcp_trans = nat64_get_tcp_trans_timeout ();
447 tcp_est = nat64_get_tcp_est_timeout ();
448 tcp_incoming_syn = nat64_get_tcp_incoming_syn_timeout ();
451 return clib_error_return (0,
452 "NAT64 disabled, multi thread not supported");
454 if (!unformat_user (input, unformat_line_input, line_input))
457 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
459 if (unformat (line_input, "udp %u", &timeout))
461 if (nat64_set_udp_timeout (timeout))
463 error = clib_error_return (0, "Invalid UDP timeout value");
467 else if (unformat (line_input, "icmp %u", &timeout))
469 if (nat64_set_icmp_timeout (timeout))
471 error = clib_error_return (0, "Invalid ICMP timeout value");
475 else if (unformat (line_input, "tcp-trans %u", &tcp_trans))
477 if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
480 clib_error_return (0, "Invalid TCP transitory tiemout value");
484 else if (unformat (line_input, "tcp-est %u", &tcp_est))
486 if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
489 clib_error_return (0,
490 "Invalid TCP established tiemout value");
495 if (unformat (line_input, "tcp-incoming-syn %u", &tcp_incoming_syn))
497 if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
500 clib_error_return (0,
501 "Invalid TCP incoming SYN tiemout value");
505 else if (unformat (line_input, "reset"))
507 nat64_set_udp_timeout (0);
508 nat64_set_icmp_timeout (0);
509 nat64_set_tcp_timeouts (0, 0, 0);
513 error = clib_error_return (0, "unknown input '%U'",
514 format_unformat_error, line_input);
520 unformat_free (line_input);
525 static clib_error_t *
526 nat64_show_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input,
527 vlib_cli_command_t * cmd)
529 nat64_main_t *nm = &nat64_main;
532 return clib_error_return (0,
533 "NAT64 disabled, multi thread not supported");
535 vlib_cli_output (vm, "NAT64 session timeouts:");
536 vlib_cli_output (vm, " UDP %usec", nat64_get_udp_timeout ());
537 vlib_cli_output (vm, " ICMP %usec", nat64_get_icmp_timeout ());
538 vlib_cli_output (vm, " TCP transitory %usec",
539 nat64_get_tcp_trans_timeout ());
540 vlib_cli_output (vm, " TCP established %usec",
541 nat64_get_tcp_est_timeout ());
542 vlib_cli_output (vm, " TCP incoming SYN %usec",
543 nat64_get_tcp_incoming_syn_timeout ());
549 nat64_cli_st_walk (nat64_db_st_entry_t * ste, void *ctx)
551 vlib_main_t *vm = ctx;
552 nat64_main_t *nm = &nat64_main;
553 nat64_db_bib_entry_t *bibe;
556 bibe = nat64_db_bib_entry_by_index (&nm->db, ste->proto, ste->bibe_index);
560 fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
564 u32 vrf_id = fib->ft_table_id;
566 if (ste->proto == SNAT_PROTOCOL_ICMP)
567 vlib_cli_output (vm, " %U %U %u %U %U %u %U vrf %u",
568 format_ip6_address, &bibe->in_addr,
569 format_ip6_address, &ste->in_r_addr,
570 clib_net_to_host_u16 (bibe->in_port),
571 format_ip4_address, &bibe->out_addr,
572 format_ip4_address, &ste->out_r_addr,
573 clib_net_to_host_u16 (bibe->out_port),
574 format_snat_protocol, bibe->proto, vrf_id);
576 vlib_cli_output (vm, " %U %u %U %u %U %u %U %u %U vrf %u",
577 format_ip6_address, &bibe->in_addr,
578 clib_net_to_host_u16 (bibe->in_port),
579 format_ip6_address, &ste->in_r_addr,
580 clib_net_to_host_u16 (ste->r_port),
581 format_ip4_address, &bibe->out_addr,
582 clib_net_to_host_u16 (bibe->out_port),
583 format_ip4_address, &ste->out_r_addr,
584 clib_net_to_host_u16 (ste->r_port),
585 format_snat_protocol, bibe->proto, vrf_id);
589 static clib_error_t *
590 nat64_show_st_command_fn (vlib_main_t * vm,
591 unformat_input_t * input, vlib_cli_command_t * cmd)
593 nat64_main_t *nm = &nat64_main;
594 unformat_input_t _line_input, *line_input = &_line_input;
595 clib_error_t *error = 0;
596 snat_protocol_t proto = 0;
599 return clib_error_return (0,
600 "NAT64 disabled, multi thread not supported");
602 if (!unformat_user (input, unformat_line_input, line_input))
605 if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
609 error = clib_error_return (0, "unknown input: '%U'",
610 format_unformat_error, line_input);
614 vlib_cli_output (vm, "NAT64 %U session table:", format_snat_protocol,
616 nat64_db_st_walk (&nm->db, proto, nat64_cli_st_walk, vm);
619 unformat_free (line_input);
624 static clib_error_t *
625 nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
626 vlib_cli_command_t * cmd)
628 nat64_main_t *nm = &nat64_main;
629 clib_error_t *error = 0;
630 unformat_input_t _line_input, *line_input = &_line_input;
633 ip6_address_t prefix;
638 return clib_error_return (0,
639 "NAT64 disabled, multi thread not supported");
641 if (!unformat_user (input, unformat_line_input, line_input))
644 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
647 (line_input, "%U/%u", unformat_ip6_address, &prefix, &plen))
649 else if (unformat (line_input, "tenant-vrf %u", &vrf_id))
651 else if (unformat (line_input, "del"))
655 error = clib_error_return (0, "unknown input: '%U'",
656 format_unformat_error, line_input);
663 error = clib_error_return (0, "NAT64 prefix must be set.");
667 rv = nat64_add_del_prefix (&prefix, (u8) plen, vrf_id, is_add);
671 case VNET_API_ERROR_NO_SUCH_ENTRY:
672 error = clib_error_return (0, "NAT64 prefix not exist.");
674 case VNET_API_ERROR_INVALID_VALUE:
675 error = clib_error_return (0, "Invalid prefix length.");
682 unformat_free (line_input);
688 nat64_cli_prefix_walk (nat64_prefix_t * p, void *ctx)
690 vlib_main_t *vm = ctx;
692 vlib_cli_output (vm, " %U/%u tenant-vrf %u",
693 format_ip6_address, &p->prefix, p->plen, p->vrf_id);
698 static clib_error_t *
699 nat64_show_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
700 vlib_cli_command_t * cmd)
702 nat64_main_t *nm = &nat64_main;
705 return clib_error_return (0,
706 "NAT64 disabled, multi thread not supported");
708 vlib_cli_output (vm, "NAT64 prefix:");
709 nat64_prefix_walk (nat64_cli_prefix_walk, vm);
718 * @cliexstart{nat64 add pool address}
719 * Add/delete NAT64 pool address.
720 * To add single NAT64 pool address use:
721 * vpp# nat64 add pool address 10.1.1.10
722 * To add NAT64 pool address range use:
723 * vpp# nat64 add pool address 10.1.1.2 - 10.1.1.5
724 * To add NAT64 pool address for specific tenant use:
725 * vpp# nat64 add pool address 10.1.1.100 tenant-vrf 100
728 VLIB_CLI_COMMAND (nat64_add_pool_address_command, static) = {
729 .path = "nat64 add pool address",
730 .short_help = "nat64 add pool address <ip4-range-start> [- <ip4-range-end>] "
731 "[tenant-vrf <vrf-id>] [del]",
732 .function = nat64_add_del_pool_addr_command_fn,
737 * @cliexstart{show nat64 pool}
739 * vpp# show nat64 pool
741 * 10.1.1.3 tenant VRF: 0
742 * 10.1.1.10 tenant VRF: 10
745 VLIB_CLI_COMMAND (show_nat64_pool_command, static) = {
746 .path = "show nat64 pool",
747 .short_help = "show nat64 pool",
748 .function = nat64_show_pool_command_fn,
753 * @cliexstart{set interface nat64}
754 * Enable/disable NAT64 feature on the interface.
755 * To enable NAT64 feature with local (IPv6) network interface
756 * GigabitEthernet0/8/0 and external (IPv4) network interface
757 * GigabitEthernet0/a/0 use:
758 * vpp# set interface nat64 in GigabitEthernet0/8/0 out GigabitEthernet0/a/0
761 VLIB_CLI_COMMAND (set_interface_nat64_command, static) = {
762 .path = "set interface nat64",
763 .short_help = "set interface nat64 in|out <intfc> [del]",
764 .function = nat64_interface_feature_command_fn,
769 * @cliexstart{show nat64 interfaces}
770 * Show interfaces with NAT64 feature.
771 * To show interfaces with NAT64 feature use:
772 * vpp# show nat64 interfaces
774 * GigabitEthernet0/8/0 in
775 * GigabitEthernet0/a/0 out
778 VLIB_CLI_COMMAND (show_nat64_interfaces_command, static) = {
779 .path = "show nat64 interfaces",
780 .short_help = "show nat64 interfaces",
781 .function = nat64_show_interfaces_command_fn,
786 * @cliexstart{nat64 add static bib}
787 * Add/delete NAT64 static BIB entry.
788 * To create NAT64 satatic BIB entry use:
789 * vpp# nat64 add static bib 2001:db8:c000:221:: 1234 10.1.1.3 5678 tcp
790 * vpp# nat64 add static bib 2001:db8:c000:221:: 1234 10.1.1.3 5678 udp vrf 10
793 VLIB_CLI_COMMAND (nat64_add_del_static_bib_command, static) = {
794 .path = "nat64 add static bib",
795 .short_help = "nat64 add static bib <ip6-addr> <port> <ip4-addr> <port> "
796 "tcp|udp|icmp [vfr <table-id>] [del]",
797 .function = nat64_add_del_static_bib_command_fn,
802 * @cliexstart{show nat64 bib}
803 * Show NAT64 BIB entries.
804 * To show NAT64 TCP BIB entries use:
805 * vpp# show nat64 bib tcp
807 * fd01:1::2 6303 10.0.0.3 62303 tcp vrf 0 dynamic 1 sessions
808 * 2001:db8:c000:221:: 1234 10.1.1.3 5678 tcp vrf 0 static 2 sessions
809 * To show NAT64 UDP BIB entries use:
810 * vpp# show nat64 bib udp
812 * fd01:1::2 6304 10.0.0.3 10546 udp vrf 0 dynamic 10 sessions
813 * 2001:db8:c000:221:: 1234 10.1.1.3 5678 udp vrf 10 static 0 sessions
814 * To show NAT64 ICMP BIB entries use:
815 * vpp# show nat64 bib icmp
817 * fd01:1::2 6305 10.0.0.3 63209 icmp vrf 10 dynamic 1 sessions
820 VLIB_CLI_COMMAND (show_nat64_bib_command, static) = {
821 .path = "show nat64 bib",
822 .short_help = "show nat64 bib tcp|udp|icmp",
823 .function = nat64_show_bib_command_fn,
828 * @cliexstart{set nat64 timeouts}
829 * Set NAT64 session timeouts (in seconds).
830 * To set NAT64 session timeoutes use use:
831 * vpp# set nat64 timeouts udp 200 icmp 30 tcp-trans 250 tcp-est 7450
832 * To reset NAT64 session timeoutes to default values use:
833 * vpp# set nat64 timeouts reset
836 VLIB_CLI_COMMAND (set_nat64_timeouts_command, static) = {
837 .path = "set nat64 timeouts",
838 .short_help = "set nat64 timeouts udp <sec> icmp <sec> tcp-trans <sec> "
839 "tcp-est <sec> tcp-incoming-syn <sec> | reset",
840 .function = nat64_set_timeouts_command_fn,
845 * @cliexstart{show nat64 tiemouts}
846 * Show NAT64 session timeouts:
847 * vpp# show nat64 tiemouts
848 * NAT64 session timeouts:
851 * TCP transitory 240sec
852 * TCP established 7440sec
853 * TCP incoming SYN 6sec
856 VLIB_CLI_COMMAND (show_nat64_timeouts_command, static) = {
857 .path = "show nat64 tiemouts",
858 .short_help = "show nat64 tiemouts",
859 .function = nat64_show_timeouts_command_fn,
864 * @cliexstart{show nat64 session table}
865 * Show NAT64 session table.
866 * To show NAT64 TCP session table use:
867 * vpp# show nat64 session table tcp
868 * NAT64 tcp session table:
869 * fd01:1::2 6303 64:ff9b::ac10:202 20 10.0.0.3 62303 172.16.2.2 20 tcp vrf 0
870 * fd01:3::2 6303 64:ff9b::ac10:202 20 10.0.10.3 21300 172.16.2.2 20 tcp vrf 10
871 * To show NAT64 UDP session table use:
872 * #vpp show nat64 session table udp
873 * NAT64 udp session table:
874 * fd01:1::2 6304 64:ff9b::ac10:202 20 10.0.0.3 10546 172.16.2.2 20 udp vrf 0
875 * fd01:3::2 6304 64:ff9b::ac10:202 20 10.0.10.3 58627 172.16.2.2 20 udp vrf 10
876 * fd01:1::2 1235 64:ff9b::a00:3 4023 10.0.0.3 24488 10.0.0.3 4023 udp vrf 0
877 * fd01:1::3 23 64:ff9b::a00:3 24488 10.0.0.3 4023 10.0.0.3 24488 udp vrf 0
878 * To show NAT64 ICMP session table use:
879 * #vpp show nat64 session table icmp
880 * NAT64 icmp session table:
881 * fd01:1::2 64:ff9b::ac10:202 6305 10.0.0.3 172.16.2.2 63209 icmp vrf 0
884 VLIB_CLI_COMMAND (show_nat64_st_command, static) = {
885 .path = "show nat64 session table",
886 .short_help = "show nat64 session table tcp|udp|icmp",
887 .function = nat64_show_st_command_fn,
892 * @cliexstart{nat64 add prefix}
893 * Set NAT64 prefix for generating IPv6 representations of IPv4 addresses.
894 * To set NAT64 global prefix use:
895 * vpp# nat64 add prefix 2001:db8::/32
896 * To set NAT64 prefix for specific tenant use:
897 * vpp# nat64 add prefix 2001:db8:122:300::/56 tenant-vrf 10
900 VLIB_CLI_COMMAND (nat64_add_del_prefix_command, static) = {
901 .path = "nat64 add prefix",
902 .short_help = "nat64 add prefix <ip6-prefix>/<plen> [tenant-vrf <vrf-id>] "
904 .function = nat64_add_del_prefix_command_fn,
909 * @cliexstart{show nat64 prefix}
911 * To show NAT64 prefix use:
912 * vpp# show nat64 prefix
914 * 2001:db8::/32 tenant-vrf 0
915 * 2001:db8:122:300::/56 tenant-vrf 10
918 VLIB_CLI_COMMAND (show_nat64_prefix_command, static) = {
919 .path = "show nat64 prefix",
920 .short_help = "show nat64 prefix",
921 .function = nat64_show_prefix_command_fn,
927 * fd.io coding-style-patch-verification: ON
930 * eval: (c-set-style "gnu")