2 * Copyright (c) 2020 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.
16 #include <vnet/fib/fib_table.h>
17 #include <nat/nat64/nat64.h>
20 nat64_plugin_enable_disable_command_fn (vlib_main_t * vm,
21 unformat_input_t * input,
22 vlib_cli_command_t * cmd)
24 unformat_input_t _line_input, *line_input = &_line_input;
25 u8 enable = 0, is_set = 0;
26 clib_error_t *error = 0;
27 nat64_config_t c = { 0 };
29 if (!unformat_user (input, unformat_line_input, line_input))
32 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
34 if (!is_set && unformat (line_input, "enable"))
36 unformat (line_input, "bib-buckets %u", &c.bib_buckets);
37 unformat (line_input, "bib-memory %u", &c.bib_memory_size);
38 unformat (line_input, "st-buckets %u", &c.st_buckets);
39 unformat (line_input, "st-memory %u", &c.st_memory_size);
42 else if (!is_set && unformat (line_input, "disable"));
45 error = clib_error_return (0, "unknown input '%U'",
46 format_unformat_error, line_input);
54 if (nat64_plugin_enable (c))
55 error = clib_error_return (0, "plugin enable failed");
59 if (nat64_plugin_disable ())
60 error = clib_error_return (0, "plugin disable failed");
63 unformat_free (line_input);
68 nat64_add_del_pool_addr_command_fn (vlib_main_t * vm,
69 unformat_input_t * input,
70 vlib_cli_command_t * cmd)
72 unformat_input_t _line_input, *line_input = &_line_input;
73 ip4_address_t start_addr, end_addr, this_addr;
74 u32 start_host_order, end_host_order;
78 clib_error_t *error = 0;
80 /* Get a line of input. */
81 if (!unformat_user (input, unformat_line_input, line_input))
84 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
86 if (unformat (line_input, "%U - %U",
87 unformat_ip4_address, &start_addr,
88 unformat_ip4_address, &end_addr))
90 else if (unformat (line_input, "tenant-vrf %u", &vrf_id))
92 else if (unformat (line_input, "%U", unformat_ip4_address, &start_addr))
93 end_addr = start_addr;
94 else if (unformat (line_input, "del"))
98 error = clib_error_return (0, "unknown input '%U'",
99 format_unformat_error, line_input);
104 start_host_order = clib_host_to_net_u32 (start_addr.as_u32);
105 end_host_order = clib_host_to_net_u32 (end_addr.as_u32);
107 if (end_host_order < start_host_order)
109 error = clib_error_return (0, "end address less than start address");
113 count = (end_host_order - start_host_order) + 1;
114 this_addr = start_addr;
116 for (i = 0; i < count; i++)
118 rv = nat64_add_del_pool_addr (0, &this_addr, vrf_id, is_add);
122 case VNET_API_ERROR_NO_SUCH_ENTRY:
124 clib_error_return (0, "NAT64 pool address %U not exist.",
125 format_ip4_address, &this_addr);
127 case VNET_API_ERROR_VALUE_EXIST:
129 clib_error_return (0, "NAT64 pool address %U exist.",
130 format_ip4_address, &this_addr);
136 increment_v4_address (&this_addr);
140 unformat_free (line_input);
146 nat64_cli_pool_walk (nat64_address_t * ap, void *ctx)
148 vlib_main_t *vm = ctx;
150 if (ap->fib_index != ~0)
153 fib = fib_table_get (ap->fib_index, FIB_PROTOCOL_IP6);
156 vlib_cli_output (vm, " %U tenant VRF: %u", format_ip4_address,
157 &ap->addr, fib->ft_table_id);
160 vlib_cli_output (vm, " %U", format_ip4_address, &ap->addr);
162 #define _(N, i, n, s) \
163 vlib_cli_output (vm, " %d busy %s ports", ap->busy_##n##_ports, s);
169 static clib_error_t *
170 nat64_show_pool_command_fn (vlib_main_t * vm,
171 unformat_input_t * input,
172 vlib_cli_command_t * cmd)
174 vlib_cli_output (vm, "NAT64 pool:");
175 nat64_pool_addr_walk (nat64_cli_pool_walk, vm);
180 static clib_error_t *
181 nat64_interface_feature_command_fn (vlib_main_t * vm,
183 input, vlib_cli_command_t * cmd)
185 unformat_input_t _line_input, *line_input = &_line_input;
186 vnet_main_t *vnm = vnet_get_main ();
187 clib_error_t *error = 0;
189 u32 *inside_sw_if_indices = 0;
190 u32 *outside_sw_if_indices = 0;
194 /* Get a line of input. */
195 if (!unformat_user (input, unformat_line_input, line_input))
198 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
200 if (unformat (line_input, "in %U", unformat_vnet_sw_interface,
202 vec_add1 (inside_sw_if_indices, sw_if_index);
203 else if (unformat (line_input, "out %U", unformat_vnet_sw_interface,
205 vec_add1 (outside_sw_if_indices, sw_if_index);
206 else if (unformat (line_input, "del"))
210 error = clib_error_return (0, "unknown input '%U'",
211 format_unformat_error, line_input);
216 if (vec_len (inside_sw_if_indices))
218 for (i = 0; i < vec_len (inside_sw_if_indices); i++)
220 sw_if_index = inside_sw_if_indices[i];
221 rv = nat64_interface_add_del (sw_if_index, 1, is_add);
224 case VNET_API_ERROR_NO_SUCH_ENTRY:
226 clib_error_return (0, "%U NAT64 feature not enabled.",
227 format_vnet_sw_if_index_name, vnm,
230 case VNET_API_ERROR_VALUE_EXIST:
232 clib_error_return (0, "%U NAT64 feature already enabled.",
233 format_vnet_sw_if_index_name, vnm,
236 case VNET_API_ERROR_INVALID_VALUE:
237 case VNET_API_ERROR_INVALID_VALUE_2:
239 clib_error_return (0,
240 "%U NAT64 feature enable/disable failed.",
241 format_vnet_sw_if_index_name, vnm,
251 if (vec_len (outside_sw_if_indices))
253 for (i = 0; i < vec_len (outside_sw_if_indices); i++)
255 sw_if_index = outside_sw_if_indices[i];
256 rv = nat64_interface_add_del (sw_if_index, 0, is_add);
259 case VNET_API_ERROR_NO_SUCH_ENTRY:
261 clib_error_return (0, "%U NAT64 feature not enabled.",
262 format_vnet_sw_if_index_name, vnm,
265 case VNET_API_ERROR_VALUE_EXIST:
267 clib_error_return (0, "%U NAT64 feature already enabled.",
268 format_vnet_sw_if_index_name, vnm,
271 case VNET_API_ERROR_INVALID_VALUE:
272 case VNET_API_ERROR_INVALID_VALUE_2:
274 clib_error_return (0,
275 "%U NAT64 feature enable/disable failed.",
276 format_vnet_sw_if_index_name, vnm,
287 unformat_free (line_input);
288 vec_free (inside_sw_if_indices);
289 vec_free (outside_sw_if_indices);
295 nat64_cli_interface_walk (nat64_interface_t * i, void *ctx)
297 vlib_main_t *vm = ctx;
298 vnet_main_t *vnm = vnet_get_main ();
300 vlib_cli_output (vm, " %U %s", format_vnet_sw_if_index_name, vnm,
302 (nat64_interface_is_inside (i)
303 && nat64_interface_is_outside (i)) ? "in out" :
304 nat64_interface_is_inside (i) ? "in" : "out");
308 static clib_error_t *
309 nat64_show_interfaces_command_fn (vlib_main_t * vm,
311 input, vlib_cli_command_t * cmd)
313 vlib_cli_output (vm, "NAT64 interfaces:");
314 nat64_interfaces_walk (nat64_cli_interface_walk, vm);
319 static clib_error_t *
320 nat64_add_del_static_bib_command_fn (vlib_main_t *
323 * input, vlib_cli_command_t * cmd)
325 unformat_input_t _line_input, *line_input = &_line_input;
326 clib_error_t *error = 0;
328 ip6_address_t in_addr;
329 ip4_address_t out_addr;
332 u32 vrf_id = 0, protocol;
333 nat_protocol_t proto = 0;
337 if (!unformat_user (input, unformat_line_input, line_input))
340 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
342 if (unformat (line_input, "%U %u", unformat_ip6_address,
345 else if (unformat (line_input, "%U %u", unformat_ip4_address,
346 &out_addr, &out_port))
348 else if (unformat (line_input, "vrf %u", &vrf_id))
350 else if (unformat (line_input, "%U", unformat_nat_protocol, &proto))
354 (line_input, "%U %U %u", unformat_ip6_address, &in_addr,
355 unformat_ip4_address, &out_addr, &protocol))
357 else if (unformat (line_input, "del"))
361 error = clib_error_return (0, "unknown input: '%U'",
362 format_unformat_error, line_input);
372 clib_error_return (0, "inside port and address must be set");
379 clib_error_return (0, "outside port and address must be set");
383 p = nat_proto_to_ip_proto (proto);
387 nat64_add_del_static_bib_entry (&in_addr, &out_addr, (u16) in_port,
388 (u16) out_port, p, vrf_id, is_add);
392 case VNET_API_ERROR_NO_SUCH_ENTRY:
393 error = clib_error_return (0, "NAT64 BIB entry not exist.");
395 case VNET_API_ERROR_VALUE_EXIST:
396 error = clib_error_return (0, "NAT64 BIB entry exist.");
398 case VNET_API_ERROR_UNSPECIFIED:
399 error = clib_error_return (0, "Crerate NAT64 BIB entry failed.");
401 case VNET_API_ERROR_INVALID_VALUE:
403 clib_error_return (0,
404 "Outside address %U and port %u already in use.",
405 format_ip4_address, &out_addr, out_port);
407 case VNET_API_ERROR_INVALID_VALUE_2:
408 error = clib_error_return (0, "Invalid outside port.");
414 unformat_free (line_input);
420 nat64_cli_bib_walk (nat64_db_bib_entry_t * bibe, void *ctx)
422 vlib_main_t *vm = ctx;
425 fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
431 case IP_PROTOCOL_ICMP:
432 case IP_PROTOCOL_TCP:
433 case IP_PROTOCOL_UDP:
434 vlib_cli_output (vm, " %U %u %U %u protocol %U vrf %u %s %u sessions",
435 format_ip6_address, &bibe->in_addr,
436 clib_net_to_host_u16 (bibe->in_port),
437 format_ip4_address, &bibe->out_addr,
438 clib_net_to_host_u16 (bibe->out_port),
440 ip_proto_to_nat_proto (bibe->proto), fib->ft_table_id,
441 bibe->is_static ? "static" : "dynamic", bibe->ses_num);
444 vlib_cli_output (vm, " %U %U protocol %u vrf %u %s %u sessions",
445 format_ip6_address, &bibe->in_addr,
446 format_ip4_address, &bibe->out_addr,
447 bibe->proto, fib->ft_table_id,
448 bibe->is_static ? "static" : "dynamic", bibe->ses_num);
453 static clib_error_t *
454 nat64_show_bib_command_fn (vlib_main_t * vm,
455 unformat_input_t * input, vlib_cli_command_t * cmd)
457 nat64_main_t *nm = &nat64_main;
458 unformat_input_t _line_input, *line_input = &_line_input;
459 clib_error_t *error = 0;
460 u32 proto = NAT_PROTOCOL_OTHER;
464 if (!unformat_user (input, unformat_line_input, line_input))
467 if (unformat (line_input, "%U", unformat_nat_protocol, &proto))
468 p = nat_proto_to_ip_proto (proto);
469 else if (unformat (line_input, "unknown"))
471 else if (unformat (line_input, "all"))
475 error = clib_error_return (0, "unknown input: '%U'",
476 format_unformat_error, line_input);
481 vlib_cli_output (vm, "NAT64 BIB entries:");
483 vlib_cli_output (vm, "NAT64 %U BIB entries:", format_nat_protocol, proto);
486 vec_foreach (db, nm->db)
487 nat64_db_bib_walk (db, p, nat64_cli_bib_walk, vm);
491 unformat_free (line_input);
496 typedef struct nat64_cli_st_walk_ctx_t_
500 } nat64_cli_st_walk_ctx_t;
503 nat64_cli_st_walk (nat64_db_st_entry_t * ste, void *arg)
505 nat64_cli_st_walk_ctx_t *ctx = arg;
506 vlib_main_t *vm = ctx->vm;
507 nat64_db_bib_entry_t *bibe;
510 bibe = nat64_db_bib_entry_by_index (ctx->db, ste->proto, ste->bibe_index);
514 fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
518 u32 vrf_id = fib->ft_table_id;
520 if (ste->proto == IP_PROTOCOL_ICMP)
521 vlib_cli_output (vm, " %U %U %u %U %U %u protocol %U vrf %u",
522 format_ip6_address, &bibe->in_addr,
523 format_ip6_address, &ste->in_r_addr,
524 clib_net_to_host_u16 (bibe->in_port),
525 format_ip4_address, &bibe->out_addr,
526 format_ip4_address, &ste->out_r_addr,
527 clib_net_to_host_u16 (bibe->out_port),
529 ip_proto_to_nat_proto (bibe->proto), vrf_id);
530 else if (ste->proto == IP_PROTOCOL_TCP || ste->proto == IP_PROTOCOL_UDP)
531 vlib_cli_output (vm, " %U %u %U %u %U %u %U %u protcol %U vrf %u",
532 format_ip6_address, &bibe->in_addr,
533 clib_net_to_host_u16 (bibe->in_port),
534 format_ip6_address, &ste->in_r_addr,
535 clib_net_to_host_u16 (ste->r_port),
536 format_ip4_address, &bibe->out_addr,
537 clib_net_to_host_u16 (bibe->out_port),
538 format_ip4_address, &ste->out_r_addr,
539 clib_net_to_host_u16 (ste->r_port),
541 ip_proto_to_nat_proto (bibe->proto), vrf_id);
543 vlib_cli_output (vm, " %U %U %U %U protocol %u vrf %u",
544 format_ip6_address, &bibe->in_addr,
545 format_ip6_address, &ste->in_r_addr,
546 format_ip4_address, &bibe->out_addr,
547 format_ip4_address, &ste->out_r_addr,
548 bibe->proto, vrf_id);
553 static clib_error_t *
554 nat64_show_st_command_fn (vlib_main_t * vm,
555 unformat_input_t * input, vlib_cli_command_t * cmd)
557 nat64_main_t *nm = &nat64_main;
558 unformat_input_t _line_input, *line_input = &_line_input;
559 clib_error_t *error = 0;
560 u32 proto = NAT_PROTOCOL_OTHER;
563 nat64_cli_st_walk_ctx_t ctx = {
567 if (!unformat_user (input, unformat_line_input, line_input))
570 if (unformat (line_input, "%U", unformat_nat_protocol, &proto))
571 p = nat_proto_to_ip_proto (proto);
572 else if (unformat (line_input, "unknown"))
574 else if (unformat (line_input, "all"))
578 error = clib_error_return (0, "unknown input: '%U'",
579 format_unformat_error, line_input);
584 vlib_cli_output (vm, "NAT64 sessions:");
586 vlib_cli_output (vm, "NAT64 %U sessions:", format_nat_protocol, proto);
588 vec_foreach (db, nm->db)
591 nat64_db_st_walk (db, p, nat64_cli_st_walk, &ctx);
596 unformat_free (line_input);
601 static clib_error_t *
602 nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
603 vlib_cli_command_t * cmd)
605 nat64_main_t *nm = &nat64_main;
606 vnet_main_t *vnm = vnet_get_main ();
607 clib_error_t *error = 0;
608 unformat_input_t _line_input, *line_input = &_line_input;
610 u32 vrf_id = 0, sw_if_index = ~0;
611 ip6_address_t prefix;
615 if (!unformat_user (input, unformat_line_input, line_input))
618 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
621 (line_input, "%U/%u", unformat_ip6_address, &prefix, &plen))
623 else if (unformat (line_input, "tenant-vrf %u", &vrf_id))
625 else if (unformat (line_input, "del"))
629 (line_input, "interface %U", unformat_vnet_sw_interface, vnm,
634 error = clib_error_return (0, "unknown input: '%U'",
635 format_unformat_error, line_input);
642 error = clib_error_return (0, "NAT64 prefix must be set.");
646 rv = nat64_add_del_prefix (&prefix, (u8) plen, vrf_id, is_add);
650 case VNET_API_ERROR_NO_SUCH_ENTRY:
651 error = clib_error_return (0, "NAT64 prefix not exist.");
653 case VNET_API_ERROR_INVALID_VALUE:
654 error = clib_error_return (0, "Invalid prefix length.");
661 * Add RX interface route, whenNAT isn't running on the real input
664 if (sw_if_index != ~0)
667 fib_prefix_t fibpfx = {
669 .fp_proto = FIB_PROTOCOL_IP6,
677 fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP6,
678 vrf_id, nm->fib_src_hi);
679 fib_table_entry_update_one_path (fib_index, &fibpfx,
684 NULL, FIB_ROUTE_PATH_INTF_RX);
688 fib_index = fib_table_find (FIB_PROTOCOL_IP6, vrf_id);
689 fib_table_entry_path_remove (fib_index, &fibpfx,
693 FIB_ROUTE_PATH_INTF_RX);
694 fib_table_unlock (fib_index, FIB_PROTOCOL_IP6, nm->fib_src_hi);
699 unformat_free (line_input);
705 nat64_cli_prefix_walk (nat64_prefix_t * p, void *ctx)
707 vlib_main_t *vm = ctx;
709 vlib_cli_output (vm, " %U/%u tenant-vrf %u",
710 format_ip6_address, &p->prefix, p->plen, p->vrf_id);
715 static clib_error_t *
716 nat64_show_prefix_command_fn (vlib_main_t * vm,
717 unformat_input_t * input,
718 vlib_cli_command_t * cmd)
720 vlib_cli_output (vm, "NAT64 prefix:");
721 nat64_prefix_walk (nat64_cli_prefix_walk, vm);
726 static clib_error_t *
727 nat64_add_interface_address_command_fn (vlib_main_t * vm,
728 unformat_input_t * input,
729 vlib_cli_command_t * cmd)
731 vnet_main_t *vnm = vnet_get_main ();
732 unformat_input_t _line_input, *line_input = &_line_input;
736 clib_error_t *error = 0;
738 /* Get a line of input. */
739 if (!unformat_user (input, unformat_line_input, line_input))
742 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
745 (line_input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index));
746 else if (unformat (line_input, "del"))
750 error = clib_error_return (0, "unknown input '%U'",
751 format_unformat_error, line_input);
756 rv = nat64_add_interface_address (sw_if_index, is_add);
760 case VNET_API_ERROR_NO_SUCH_ENTRY:
761 error = clib_error_return (0, "entry not exist");
763 case VNET_API_ERROR_VALUE_EXIST:
764 error = clib_error_return (0, "entry exist");
771 unformat_free (line_input);
779 * @cliexstart{nat64 plugin}
780 * Enable/disable NAT64 plugin.
781 * To enable NAT64 plugin use:
782 * vpp# nat64 plugin enable
783 * To enable NAT64 plugin and configure buckets/memory:
784 * vpp# nat64 plugin enable bib-buckets <n> bib-memory <s> \
785 * st-buckets <n> st-memory <s>
786 * To disable NAT64 plugin:
787 * vpp# nat64 plugin disable
790 VLIB_CLI_COMMAND (nat64_plugin_enable_disable_command, static) =
792 .path = "nat64 plugin",
793 .short_help = "nat64 plugin <enable "
794 "[bib-buckets <count>] [bib-memory <size>] "
795 "[st-buckets <count>] [st-memory <size>] | disable>",
796 .function = nat64_plugin_enable_disable_command_fn,
801 * @cliexstart{nat64 add pool address}
802 * Add/delete NAT64 pool address.
803 * To add single NAT64 pool address use:
804 * vpp# nat64 add pool address 10.1.1.10
805 * To add NAT64 pool address range use:
806 * vpp# nat64 add pool address 10.1.1.2 - 10.1.1.5
807 * To add NAT64 pool address for specific tenant use:
808 * vpp# nat64 add pool address 10.1.1.100 tenant-vrf 100
811 VLIB_CLI_COMMAND (nat64_add_pool_address_command, static) = {
812 .path = "nat64 add pool address",
813 .short_help = "nat64 add pool address <ip4-range-start> [- <ip4-range-end>] "
814 "[tenant-vrf <vrf-id>] [del]",
815 .function = nat64_add_del_pool_addr_command_fn,
820 * @cliexstart{show nat64 pool}
822 * vpp# show nat64 pool
824 * 10.1.1.3 tenant VRF: 0
825 * 10.1.1.10 tenant VRF: 10
828 VLIB_CLI_COMMAND (show_nat64_pool_command, static) = {
829 .path = "show nat64 pool",
830 .short_help = "show nat64 pool",
831 .function = nat64_show_pool_command_fn,
836 * @cliexstart{set interface nat64}
837 * Enable/disable NAT64 feature on the interface.
838 * To enable NAT64 feature with local (IPv6) network interface
839 * GigabitEthernet0/8/0 and external (IPv4) network interface
840 * GigabitEthernet0/a/0 use:
841 * vpp# set interface nat64 in GigabitEthernet0/8/0 out GigabitEthernet0/a/0
844 VLIB_CLI_COMMAND (set_interface_nat64_command, static) = {
845 .path = "set interface nat64",
846 .short_help = "set interface nat64 in|out <intfc> [del]",
847 .function = nat64_interface_feature_command_fn,
852 * @cliexstart{show nat64 interfaces}
853 * Show interfaces with NAT64 feature.
854 * To show interfaces with NAT64 feature use:
855 * vpp# show nat64 interfaces
857 * GigabitEthernet0/8/0 in
858 * GigabitEthernet0/a/0 out
861 VLIB_CLI_COMMAND (show_nat64_interfaces_command, static) = {
862 .path = "show nat64 interfaces",
863 .short_help = "show nat64 interfaces",
864 .function = nat64_show_interfaces_command_fn,
869 * @cliexstart{nat64 add static bib}
870 * Add/delete NAT64 static BIB entry.
871 * To create NAT64 satatic BIB entry use:
872 * vpp# nat64 add static bib 2001:db8:c000:221:: 1234 10.1.1.3 5678 tcp
873 * vpp# nat64 add static bib 2001:db8:c000:221:: 1234 10.1.1.3 5678 udp vrf 10
876 VLIB_CLI_COMMAND (nat64_add_del_static_bib_command, static) = {
877 .path = "nat64 add static bib",
878 .short_help = "nat64 add static bib <ip6-addr> <port> <ip4-addr> <port> "
879 "tcp|udp|icmp [vfr <table-id>] [del]",
880 .function = nat64_add_del_static_bib_command_fn,
885 * @cliexstart{show nat64 bib}
886 * Show NAT64 BIB entries.
887 * To show NAT64 TCP BIB entries use:
888 * vpp# show nat64 bib tcp
890 * fd01:1::2 6303 10.0.0.3 62303 tcp vrf 0 dynamic 1 sessions
891 * 2001:db8:c000:221:: 1234 10.1.1.3 5678 tcp vrf 0 static 2 sessions
892 * To show NAT64 UDP BIB entries use:
893 * vpp# show nat64 bib udp
895 * fd01:1::2 6304 10.0.0.3 10546 udp vrf 0 dynamic 10 sessions
896 * 2001:db8:c000:221:: 1234 10.1.1.3 5678 udp vrf 10 static 0 sessions
897 * To show NAT64 ICMP BIB entries use:
898 * vpp# show nat64 bib icmp
900 * fd01:1::2 6305 10.0.0.3 63209 icmp vrf 10 dynamic 1 sessions
903 VLIB_CLI_COMMAND (show_nat64_bib_command, static) = {
904 .path = "show nat64 bib",
905 .short_help = "show nat64 bib all|tcp|udp|icmp|unknown",
906 .function = nat64_show_bib_command_fn,
911 * @cliexstart{show nat64 session table}
912 * Show NAT64 session table.
913 * To show NAT64 TCP session table use:
914 * vpp# show nat64 session table tcp
915 * NAT64 tcp session table:
916 * fd01:1::2 6303 64:ff9b::ac10:202 20 10.0.0.3 62303 172.16.2.2 20 tcp vrf 0
917 * fd01:3::2 6303 64:ff9b::ac10:202 20 10.0.10.3 21300 172.16.2.2 20 tcp vrf 10
918 * To show NAT64 UDP session table use:
919 * #vpp show nat64 session table udp
920 * NAT64 udp session table:
921 * fd01:1::2 6304 64:ff9b::ac10:202 20 10.0.0.3 10546 172.16.2.2 20 udp vrf 0
922 * fd01:3::2 6304 64:ff9b::ac10:202 20 10.0.10.3 58627 172.16.2.2 20 udp vrf 10
923 * fd01:1::2 1235 64:ff9b::a00:3 4023 10.0.0.3 24488 10.0.0.3 4023 udp vrf 0
924 * fd01:1::3 23 64:ff9b::a00:3 24488 10.0.0.3 4023 10.0.0.3 24488 udp vrf 0
925 * To show NAT64 ICMP session table use:
926 * #vpp show nat64 session table icmp
927 * NAT64 icmp session table:
928 * fd01:1::2 64:ff9b::ac10:202 6305 10.0.0.3 172.16.2.2 63209 icmp vrf 0
931 VLIB_CLI_COMMAND (show_nat64_st_command, static) = {
932 .path = "show nat64 session table",
933 .short_help = "show nat64 session table all|tcp|udp|icmp|unknown",
934 .function = nat64_show_st_command_fn,
939 * @cliexstart{nat64 add prefix}
940 * Set NAT64 prefix for generating IPv6 representations of IPv4 addresses.
941 * To set NAT64 global prefix use:
942 * vpp# nat64 add prefix 2001:db8::/32
943 * To set NAT64 prefix for specific tenant use:
944 * vpp# nat64 add prefix 2001:db8:122:300::/56 tenant-vrf 10
947 VLIB_CLI_COMMAND (nat64_add_del_prefix_command, static) = {
948 .path = "nat64 add prefix",
949 .short_help = "nat64 add prefix <ip6-prefix>/<plen> [tenant-vrf <vrf-id>] "
950 "[del] [interface <interface]",
951 .function = nat64_add_del_prefix_command_fn,
956 * @cliexstart{show nat64 prefix}
958 * To show NAT64 prefix use:
959 * vpp# show nat64 prefix
961 * 2001:db8::/32 tenant-vrf 0
962 * 2001:db8:122:300::/56 tenant-vrf 10
965 VLIB_CLI_COMMAND (show_nat64_prefix_command, static) = {
966 .path = "show nat64 prefix",
967 .short_help = "show nat64 prefix",
968 .function = nat64_show_prefix_command_fn,
973 * @cliexstart{nat64 add interface address}
974 * Add/delete NAT64 pool address from specific (DHCP addressed) interface.
975 * To add NAT64 pool address from specific interface use:
976 * vpp# nat64 add interface address GigabitEthernet0/8/0
979 VLIB_CLI_COMMAND (nat64_add_interface_address_command, static) = {
980 .path = "nat64 add interface address",
981 .short_help = "nat64 add interface address <interface> [del]",
982 .function = nat64_add_interface_address_command_fn,
987 * fd.io coding-style-patch-verification: ON
990 * eval: (c-set-style "gnu")