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>
19 #define NAT64_EXPECTED_ARGUMENT "expected required argument(s)"
22 nat64_plugin_enable_disable_command_fn (vlib_main_t * vm,
23 unformat_input_t * input,
24 vlib_cli_command_t * cmd)
26 unformat_input_t _line_input, *line_input = &_line_input;
27 u8 enable = 0, is_set = 0;
28 clib_error_t *error = 0;
29 nat64_config_t c = { 0 };
31 if (!unformat_user (input, unformat_line_input, line_input))
32 return clib_error_return (0, NAT64_EXPECTED_ARGUMENT);
34 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
36 if (!is_set && unformat (line_input, "enable"))
38 unformat (line_input, "bib-buckets %u", &c.bib_buckets);
39 unformat (line_input, "bib-memory %u", &c.bib_memory_size);
40 unformat (line_input, "st-buckets %u", &c.st_buckets);
41 unformat (line_input, "st-memory %u", &c.st_memory_size);
44 else if (!is_set && unformat (line_input, "disable"));
47 error = clib_error_return (0, "unknown input '%U'",
48 format_unformat_error, line_input);
56 if (nat64_plugin_enable (c))
57 error = clib_error_return (0, "plugin enable failed");
61 if (nat64_plugin_disable ())
62 error = clib_error_return (0, "plugin disable failed");
65 unformat_free (line_input);
70 nat64_add_del_pool_addr_command_fn (vlib_main_t * vm,
71 unformat_input_t * input,
72 vlib_cli_command_t * cmd)
74 unformat_input_t _line_input, *line_input = &_line_input;
75 ip4_address_t start_addr, end_addr, this_addr;
76 u32 start_host_order, end_host_order;
80 clib_error_t *error = 0;
82 /* Get a line of input. */
83 if (!unformat_user (input, unformat_line_input, line_input))
84 return clib_error_return (0, NAT64_EXPECTED_ARGUMENT);
86 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
88 if (unformat (line_input, "%U - %U",
89 unformat_ip4_address, &start_addr,
90 unformat_ip4_address, &end_addr))
92 else if (unformat (line_input, "tenant-vrf %u", &vrf_id))
94 else if (unformat (line_input, "%U", unformat_ip4_address, &start_addr))
95 end_addr = start_addr;
96 else if (unformat (line_input, "del"))
100 error = clib_error_return (0, "unknown input '%U'",
101 format_unformat_error, line_input);
106 start_host_order = clib_host_to_net_u32 (start_addr.as_u32);
107 end_host_order = clib_host_to_net_u32 (end_addr.as_u32);
109 if (end_host_order < start_host_order)
111 error = clib_error_return (0, "end address less than start address");
115 count = (end_host_order - start_host_order) + 1;
116 this_addr = start_addr;
118 for (i = 0; i < count; i++)
120 rv = nat64_add_del_pool_addr (0, &this_addr, vrf_id, is_add);
124 case VNET_API_ERROR_NO_SUCH_ENTRY:
126 clib_error_return (0, "NAT64 pool address %U not exist.",
127 format_ip4_address, &this_addr);
129 case VNET_API_ERROR_VALUE_EXIST:
131 clib_error_return (0, "NAT64 pool address %U exist.",
132 format_ip4_address, &this_addr);
138 increment_v4_address (&this_addr);
142 unformat_free (line_input);
148 nat64_cli_pool_walk (nat64_address_t * ap, void *ctx)
150 vlib_main_t *vm = ctx;
152 if (ap->fib_index != ~0)
155 fib = fib_table_get (ap->fib_index, FIB_PROTOCOL_IP6);
158 vlib_cli_output (vm, " %U tenant VRF: %u", format_ip4_address,
159 &ap->addr, fib->ft_table_id);
162 vlib_cli_output (vm, " %U", format_ip4_address, &ap->addr);
164 #define _(N, i, n, s) \
165 vlib_cli_output (vm, " %d busy %s ports", ap->busy_##n##_ports, s);
171 static clib_error_t *
172 nat64_show_pool_command_fn (vlib_main_t * vm,
173 unformat_input_t * input,
174 vlib_cli_command_t * cmd)
176 vlib_cli_output (vm, "NAT64 pool:");
177 nat64_pool_addr_walk (nat64_cli_pool_walk, vm);
182 static clib_error_t *
183 nat64_interface_feature_command_fn (vlib_main_t * vm,
185 input, vlib_cli_command_t * cmd)
187 unformat_input_t _line_input, *line_input = &_line_input;
188 vnet_main_t *vnm = vnet_get_main ();
189 clib_error_t *error = 0;
191 u32 *inside_sw_if_indices = 0;
192 u32 *outside_sw_if_indices = 0;
196 /* Get a line of input. */
197 if (!unformat_user (input, unformat_line_input, line_input))
198 return clib_error_return (0, NAT64_EXPECTED_ARGUMENT);
200 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
202 if (unformat (line_input, "in %U", unformat_vnet_sw_interface,
204 vec_add1 (inside_sw_if_indices, sw_if_index);
205 else if (unformat (line_input, "out %U", unformat_vnet_sw_interface,
207 vec_add1 (outside_sw_if_indices, sw_if_index);
208 else if (unformat (line_input, "del"))
212 error = clib_error_return (0, "unknown input '%U'",
213 format_unformat_error, line_input);
218 if (vec_len (inside_sw_if_indices))
220 for (i = 0; i < vec_len (inside_sw_if_indices); i++)
222 sw_if_index = inside_sw_if_indices[i];
223 rv = nat64_interface_add_del (sw_if_index, 1, is_add);
226 case VNET_API_ERROR_NO_SUCH_ENTRY:
228 clib_error_return (0, "%U NAT64 feature not enabled.",
229 format_vnet_sw_if_index_name, vnm,
232 case VNET_API_ERROR_VALUE_EXIST:
234 clib_error_return (0, "%U NAT64 feature already enabled.",
235 format_vnet_sw_if_index_name, vnm,
238 case VNET_API_ERROR_INVALID_VALUE:
239 case VNET_API_ERROR_INVALID_VALUE_2:
241 clib_error_return (0,
242 "%U NAT64 feature enable/disable failed.",
243 format_vnet_sw_if_index_name, vnm,
253 if (vec_len (outside_sw_if_indices))
255 for (i = 0; i < vec_len (outside_sw_if_indices); i++)
257 sw_if_index = outside_sw_if_indices[i];
258 rv = nat64_interface_add_del (sw_if_index, 0, is_add);
261 case VNET_API_ERROR_NO_SUCH_ENTRY:
263 clib_error_return (0, "%U NAT64 feature not enabled.",
264 format_vnet_sw_if_index_name, vnm,
267 case VNET_API_ERROR_VALUE_EXIST:
269 clib_error_return (0, "%U NAT64 feature already enabled.",
270 format_vnet_sw_if_index_name, vnm,
273 case VNET_API_ERROR_INVALID_VALUE:
274 case VNET_API_ERROR_INVALID_VALUE_2:
276 clib_error_return (0,
277 "%U NAT64 feature enable/disable failed.",
278 format_vnet_sw_if_index_name, vnm,
289 unformat_free (line_input);
290 vec_free (inside_sw_if_indices);
291 vec_free (outside_sw_if_indices);
297 nat64_cli_interface_walk (nat64_interface_t * i, void *ctx)
299 vlib_main_t *vm = ctx;
300 vnet_main_t *vnm = vnet_get_main ();
302 vlib_cli_output (vm, " %U %s", format_vnet_sw_if_index_name, vnm,
304 (nat64_interface_is_inside (i)
305 && nat64_interface_is_outside (i)) ? "in out" :
306 nat64_interface_is_inside (i) ? "in" : "out");
310 static clib_error_t *
311 nat64_show_interfaces_command_fn (vlib_main_t * vm,
313 input, vlib_cli_command_t * cmd)
315 vlib_cli_output (vm, "NAT64 interfaces:");
316 nat64_interfaces_walk (nat64_cli_interface_walk, vm);
321 static clib_error_t *
322 nat64_add_del_static_bib_command_fn (vlib_main_t *
325 * input, vlib_cli_command_t * cmd)
327 unformat_input_t _line_input, *line_input = &_line_input;
328 clib_error_t *error = 0;
330 ip6_address_t in_addr;
331 ip4_address_t out_addr;
334 u32 vrf_id = 0, protocol;
335 nat_protocol_t proto = 0;
339 if (!unformat_user (input, unformat_line_input, line_input))
340 return clib_error_return (0, NAT64_EXPECTED_ARGUMENT);
342 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
344 if (unformat (line_input, "%U %u", unformat_ip6_address,
347 else if (unformat (line_input, "%U %u", unformat_ip4_address,
348 &out_addr, &out_port))
350 else if (unformat (line_input, "vrf %u", &vrf_id))
352 else if (unformat (line_input, "%U", unformat_nat_protocol, &proto))
356 (line_input, "%U %U %u", unformat_ip6_address, &in_addr,
357 unformat_ip4_address, &out_addr, &protocol))
359 else if (unformat (line_input, "del"))
363 error = clib_error_return (0, "unknown input: '%U'",
364 format_unformat_error, line_input);
374 clib_error_return (0, "inside port and address must be set");
381 clib_error_return (0, "outside port and address must be set");
385 p = nat_proto_to_ip_proto (proto);
389 nat64_add_del_static_bib_entry (&in_addr, &out_addr, (u16) in_port,
390 (u16) out_port, p, vrf_id, is_add);
394 case VNET_API_ERROR_NO_SUCH_ENTRY:
395 error = clib_error_return (0, "NAT64 BIB entry not exist.");
397 case VNET_API_ERROR_VALUE_EXIST:
398 error = clib_error_return (0, "NAT64 BIB entry exist.");
400 case VNET_API_ERROR_UNSPECIFIED:
401 error = clib_error_return (0, "Crerate NAT64 BIB entry failed.");
403 case VNET_API_ERROR_INVALID_VALUE:
405 clib_error_return (0,
406 "Outside address %U and port %u already in use.",
407 format_ip4_address, &out_addr, out_port);
409 case VNET_API_ERROR_INVALID_VALUE_2:
410 error = clib_error_return (0, "Invalid outside port.");
416 unformat_free (line_input);
422 nat64_cli_bib_walk (nat64_db_bib_entry_t * bibe, void *ctx)
424 vlib_main_t *vm = ctx;
427 fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
433 case IP_PROTOCOL_ICMP:
434 case IP_PROTOCOL_TCP:
435 case IP_PROTOCOL_UDP:
436 vlib_cli_output (vm, " %U %u %U %u protocol %U vrf %u %s %u sessions",
437 format_ip6_address, &bibe->in_addr,
438 clib_net_to_host_u16 (bibe->in_port),
439 format_ip4_address, &bibe->out_addr,
440 clib_net_to_host_u16 (bibe->out_port),
442 ip_proto_to_nat_proto (bibe->proto), fib->ft_table_id,
443 bibe->is_static ? "static" : "dynamic", bibe->ses_num);
446 vlib_cli_output (vm, " %U %U protocol %u vrf %u %s %u sessions",
447 format_ip6_address, &bibe->in_addr,
448 format_ip4_address, &bibe->out_addr,
449 bibe->proto, fib->ft_table_id,
450 bibe->is_static ? "static" : "dynamic", bibe->ses_num);
455 static clib_error_t *
456 nat64_show_bib_command_fn (vlib_main_t * vm,
457 unformat_input_t * input, vlib_cli_command_t * cmd)
459 nat64_main_t *nm = &nat64_main;
460 unformat_input_t _line_input, *line_input = &_line_input;
461 clib_error_t *error = 0;
462 u32 proto = NAT_PROTOCOL_OTHER;
466 if (!unformat_user (input, unformat_line_input, line_input))
467 return clib_error_return (0, NAT64_EXPECTED_ARGUMENT);
469 if (unformat (line_input, "%U", unformat_nat_protocol, &proto))
470 p = nat_proto_to_ip_proto (proto);
471 else if (unformat (line_input, "unknown"))
473 else if (unformat (line_input, "all"))
477 error = clib_error_return (0, "unknown input: '%U'",
478 format_unformat_error, line_input);
483 vlib_cli_output (vm, "NAT64 BIB entries:");
485 vlib_cli_output (vm, "NAT64 %U BIB entries:", format_nat_protocol, proto);
488 vec_foreach (db, nm->db)
489 nat64_db_bib_walk (db, p, nat64_cli_bib_walk, vm);
493 unformat_free (line_input);
498 typedef struct nat64_cli_st_walk_ctx_t_
502 } nat64_cli_st_walk_ctx_t;
505 nat64_cli_st_walk (nat64_db_st_entry_t * ste, void *arg)
507 nat64_cli_st_walk_ctx_t *ctx = arg;
508 vlib_main_t *vm = ctx->vm;
509 nat64_db_bib_entry_t *bibe;
512 bibe = nat64_db_bib_entry_by_index (ctx->db, ste->proto, ste->bibe_index);
516 fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
520 u32 vrf_id = fib->ft_table_id;
522 if (ste->proto == IP_PROTOCOL_ICMP)
523 vlib_cli_output (vm, " %U %U %u %U %U %u protocol %U vrf %u",
524 format_ip6_address, &bibe->in_addr,
525 format_ip6_address, &ste->in_r_addr,
526 clib_net_to_host_u16 (bibe->in_port),
527 format_ip4_address, &bibe->out_addr,
528 format_ip4_address, &ste->out_r_addr,
529 clib_net_to_host_u16 (bibe->out_port),
531 ip_proto_to_nat_proto (bibe->proto), vrf_id);
532 else if (ste->proto == IP_PROTOCOL_TCP || ste->proto == IP_PROTOCOL_UDP)
533 vlib_cli_output (vm, " %U %u %U %u %U %u %U %u protcol %U vrf %u",
534 format_ip6_address, &bibe->in_addr,
535 clib_net_to_host_u16 (bibe->in_port),
536 format_ip6_address, &ste->in_r_addr,
537 clib_net_to_host_u16 (ste->r_port),
538 format_ip4_address, &bibe->out_addr,
539 clib_net_to_host_u16 (bibe->out_port),
540 format_ip4_address, &ste->out_r_addr,
541 clib_net_to_host_u16 (ste->r_port),
543 ip_proto_to_nat_proto (bibe->proto), vrf_id);
545 vlib_cli_output (vm, " %U %U %U %U protocol %u vrf %u",
546 format_ip6_address, &bibe->in_addr,
547 format_ip6_address, &ste->in_r_addr,
548 format_ip4_address, &bibe->out_addr,
549 format_ip4_address, &ste->out_r_addr,
550 bibe->proto, vrf_id);
555 static clib_error_t *
556 nat64_show_st_command_fn (vlib_main_t * vm,
557 unformat_input_t * input, vlib_cli_command_t * cmd)
559 nat64_main_t *nm = &nat64_main;
560 unformat_input_t _line_input, *line_input = &_line_input;
561 clib_error_t *error = 0;
562 u32 proto = NAT_PROTOCOL_OTHER;
565 nat64_cli_st_walk_ctx_t ctx = {
569 if (!unformat_user (input, unformat_line_input, line_input))
570 return clib_error_return (0, NAT64_EXPECTED_ARGUMENT);
572 if (unformat (line_input, "%U", unformat_nat_protocol, &proto))
573 p = nat_proto_to_ip_proto (proto);
574 else if (unformat (line_input, "unknown"))
576 else if (unformat (line_input, "all"))
580 error = clib_error_return (0, "unknown input: '%U'",
581 format_unformat_error, line_input);
586 vlib_cli_output (vm, "NAT64 sessions:");
588 vlib_cli_output (vm, "NAT64 %U sessions:", format_nat_protocol, proto);
590 vec_foreach (db, nm->db)
593 nat64_db_st_walk (db, p, nat64_cli_st_walk, &ctx);
598 unformat_free (line_input);
603 static clib_error_t *
604 nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
605 vlib_cli_command_t * cmd)
607 nat64_main_t *nm = &nat64_main;
608 vnet_main_t *vnm = vnet_get_main ();
609 clib_error_t *error = 0;
610 unformat_input_t _line_input, *line_input = &_line_input;
612 u32 vrf_id = 0, sw_if_index = ~0;
613 ip6_address_t prefix;
617 if (!unformat_user (input, unformat_line_input, line_input))
618 return clib_error_return (0, NAT64_EXPECTED_ARGUMENT);
620 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
623 (line_input, "%U/%u", unformat_ip6_address, &prefix, &plen))
625 else if (unformat (line_input, "tenant-vrf %u", &vrf_id))
627 else if (unformat (line_input, "del"))
631 (line_input, "interface %U", unformat_vnet_sw_interface, vnm,
636 error = clib_error_return (0, "unknown input: '%U'",
637 format_unformat_error, line_input);
644 error = clib_error_return (0, "NAT64 prefix must be set.");
648 rv = nat64_add_del_prefix (&prefix, (u8) plen, vrf_id, is_add);
652 case VNET_API_ERROR_NO_SUCH_ENTRY:
653 error = clib_error_return (0, "NAT64 prefix not exist.");
655 case VNET_API_ERROR_INVALID_VALUE:
656 error = clib_error_return (0, "Invalid prefix length.");
663 * Add RX interface route, whenNAT isn't running on the real input
666 if (sw_if_index != ~0)
669 fib_prefix_t fibpfx = {
671 .fp_proto = FIB_PROTOCOL_IP6,
679 fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP6,
680 vrf_id, nm->fib_src_hi);
681 fib_table_entry_update_one_path (fib_index, &fibpfx,
686 NULL, FIB_ROUTE_PATH_INTF_RX);
690 fib_index = fib_table_find (FIB_PROTOCOL_IP6, vrf_id);
691 fib_table_entry_path_remove (fib_index, &fibpfx,
695 FIB_ROUTE_PATH_INTF_RX);
696 fib_table_unlock (fib_index, FIB_PROTOCOL_IP6, nm->fib_src_hi);
701 unformat_free (line_input);
707 nat64_cli_prefix_walk (nat64_prefix_t * p, void *ctx)
709 vlib_main_t *vm = ctx;
711 vlib_cli_output (vm, " %U/%u tenant-vrf %u",
712 format_ip6_address, &p->prefix, p->plen, p->vrf_id);
717 static clib_error_t *
718 nat64_show_prefix_command_fn (vlib_main_t * vm,
719 unformat_input_t * input,
720 vlib_cli_command_t * cmd)
722 vlib_cli_output (vm, "NAT64 prefix:");
723 nat64_prefix_walk (nat64_cli_prefix_walk, vm);
728 static clib_error_t *
729 nat64_add_interface_address_command_fn (vlib_main_t * vm,
730 unformat_input_t * input,
731 vlib_cli_command_t * cmd)
733 vnet_main_t *vnm = vnet_get_main ();
734 unformat_input_t _line_input, *line_input = &_line_input;
738 clib_error_t *error = 0;
740 /* Get a line of input. */
741 if (!unformat_user (input, unformat_line_input, line_input))
742 return clib_error_return (0, NAT64_EXPECTED_ARGUMENT);
744 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
747 (line_input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index));
748 else if (unformat (line_input, "del"))
752 error = clib_error_return (0, "unknown input '%U'",
753 format_unformat_error, line_input);
758 rv = nat64_add_interface_address (sw_if_index, is_add);
762 case VNET_API_ERROR_NO_SUCH_ENTRY:
763 error = clib_error_return (0, "entry not exist");
765 case VNET_API_ERROR_VALUE_EXIST:
766 error = clib_error_return (0, "entry exist");
773 unformat_free (line_input);
781 * @cliexstart{nat64 plugin}
782 * Enable/disable NAT64 plugin.
783 * To enable NAT64 plugin use:
784 * vpp# nat64 plugin enable
785 * To enable NAT64 plugin and configure buckets/memory:
786 * vpp# nat64 plugin enable bib-buckets <n> bib-memory <s> \
787 * st-buckets <n> st-memory <s>
788 * To disable NAT64 plugin:
789 * vpp# nat64 plugin disable
792 VLIB_CLI_COMMAND (nat64_plugin_enable_disable_command, static) =
794 .path = "nat64 plugin",
795 .short_help = "nat64 plugin <enable "
796 "[bib-buckets <count>] [bib-memory <size>] "
797 "[st-buckets <count>] [st-memory <size>] | disable>",
798 .function = nat64_plugin_enable_disable_command_fn,
803 * @cliexstart{nat64 add pool address}
804 * Add/delete NAT64 pool address.
805 * To add single NAT64 pool address use:
806 * vpp# nat64 add pool address 10.1.1.10
807 * To add NAT64 pool address range use:
808 * vpp# nat64 add pool address 10.1.1.2 - 10.1.1.5
809 * To add NAT64 pool address for specific tenant use:
810 * vpp# nat64 add pool address 10.1.1.100 tenant-vrf 100
813 VLIB_CLI_COMMAND (nat64_add_pool_address_command, static) = {
814 .path = "nat64 add pool address",
815 .short_help = "nat64 add pool address <ip4-range-start> [- <ip4-range-end>] "
816 "[tenant-vrf <vrf-id>] [del]",
817 .function = nat64_add_del_pool_addr_command_fn,
822 * @cliexstart{show nat64 pool}
824 * vpp# show nat64 pool
826 * 10.1.1.3 tenant VRF: 0
827 * 10.1.1.10 tenant VRF: 10
830 VLIB_CLI_COMMAND (show_nat64_pool_command, static) = {
831 .path = "show nat64 pool",
832 .short_help = "show nat64 pool",
833 .function = nat64_show_pool_command_fn,
838 * @cliexstart{set interface nat64}
839 * Enable/disable NAT64 feature on the interface.
840 * To enable NAT64 feature with local (IPv6) network interface
841 * GigabitEthernet0/8/0 and external (IPv4) network interface
842 * GigabitEthernet0/a/0 use:
843 * vpp# set interface nat64 in GigabitEthernet0/8/0 out GigabitEthernet0/a/0
846 VLIB_CLI_COMMAND (set_interface_nat64_command, static) = {
847 .path = "set interface nat64",
848 .short_help = "set interface nat64 in|out <intfc> [del]",
849 .function = nat64_interface_feature_command_fn,
854 * @cliexstart{show nat64 interfaces}
855 * Show interfaces with NAT64 feature.
856 * To show interfaces with NAT64 feature use:
857 * vpp# show nat64 interfaces
859 * GigabitEthernet0/8/0 in
860 * GigabitEthernet0/a/0 out
863 VLIB_CLI_COMMAND (show_nat64_interfaces_command, static) = {
864 .path = "show nat64 interfaces",
865 .short_help = "show nat64 interfaces",
866 .function = nat64_show_interfaces_command_fn,
871 * @cliexstart{nat64 add static bib}
872 * Add/delete NAT64 static BIB entry.
873 * To create NAT64 satatic BIB entry use:
874 * vpp# nat64 add static bib 2001:db8:c000:221:: 1234 10.1.1.3 5678 tcp
875 * vpp# nat64 add static bib 2001:db8:c000:221:: 1234 10.1.1.3 5678 udp vrf 10
878 VLIB_CLI_COMMAND (nat64_add_del_static_bib_command, static) = {
879 .path = "nat64 add static bib",
880 .short_help = "nat64 add static bib <ip6-addr> <port> <ip4-addr> <port> "
881 "tcp|udp|icmp [vfr <table-id>] [del]",
882 .function = nat64_add_del_static_bib_command_fn,
887 * @cliexstart{show nat64 bib}
888 * Show NAT64 BIB entries.
889 * To show NAT64 TCP BIB entries use:
890 * vpp# show nat64 bib tcp
892 * fd01:1::2 6303 10.0.0.3 62303 tcp vrf 0 dynamic 1 sessions
893 * 2001:db8:c000:221:: 1234 10.1.1.3 5678 tcp vrf 0 static 2 sessions
894 * To show NAT64 UDP BIB entries use:
895 * vpp# show nat64 bib udp
897 * fd01:1::2 6304 10.0.0.3 10546 udp vrf 0 dynamic 10 sessions
898 * 2001:db8:c000:221:: 1234 10.1.1.3 5678 udp vrf 10 static 0 sessions
899 * To show NAT64 ICMP BIB entries use:
900 * vpp# show nat64 bib icmp
902 * fd01:1::2 6305 10.0.0.3 63209 icmp vrf 10 dynamic 1 sessions
905 VLIB_CLI_COMMAND (show_nat64_bib_command, static) = {
906 .path = "show nat64 bib",
907 .short_help = "show nat64 bib all|tcp|udp|icmp|unknown",
908 .function = nat64_show_bib_command_fn,
913 * @cliexstart{show nat64 session table}
914 * Show NAT64 session table.
915 * To show NAT64 TCP session table use:
916 * vpp# show nat64 session table tcp
917 * NAT64 tcp session table:
918 * fd01:1::2 6303 64:ff9b::ac10:202 20 10.0.0.3 62303 172.16.2.2 20 tcp vrf 0
919 * fd01:3::2 6303 64:ff9b::ac10:202 20 10.0.10.3 21300 172.16.2.2 20 tcp vrf 10
920 * To show NAT64 UDP session table use:
921 * #vpp show nat64 session table udp
922 * NAT64 udp session table:
923 * fd01:1::2 6304 64:ff9b::ac10:202 20 10.0.0.3 10546 172.16.2.2 20 udp vrf 0
924 * fd01:3::2 6304 64:ff9b::ac10:202 20 10.0.10.3 58627 172.16.2.2 20 udp vrf 10
925 * fd01:1::2 1235 64:ff9b::a00:3 4023 10.0.0.3 24488 10.0.0.3 4023 udp vrf 0
926 * fd01:1::3 23 64:ff9b::a00:3 24488 10.0.0.3 4023 10.0.0.3 24488 udp vrf 0
927 * To show NAT64 ICMP session table use:
928 * #vpp show nat64 session table icmp
929 * NAT64 icmp session table:
930 * fd01:1::2 64:ff9b::ac10:202 6305 10.0.0.3 172.16.2.2 63209 icmp vrf 0
933 VLIB_CLI_COMMAND (show_nat64_st_command, static) = {
934 .path = "show nat64 session table",
935 .short_help = "show nat64 session table all|tcp|udp|icmp|unknown",
936 .function = nat64_show_st_command_fn,
941 * @cliexstart{nat64 add prefix}
942 * Set NAT64 prefix for generating IPv6 representations of IPv4 addresses.
943 * To set NAT64 global prefix use:
944 * vpp# nat64 add prefix 2001:db8::/32
945 * To set NAT64 prefix for specific tenant use:
946 * vpp# nat64 add prefix 2001:db8:122:300::/56 tenant-vrf 10
949 VLIB_CLI_COMMAND (nat64_add_del_prefix_command, static) = {
950 .path = "nat64 add prefix",
951 .short_help = "nat64 add prefix <ip6-prefix>/<plen> [tenant-vrf <vrf-id>] "
952 "[del] [interface <interface]",
953 .function = nat64_add_del_prefix_command_fn,
958 * @cliexstart{show nat64 prefix}
960 * To show NAT64 prefix use:
961 * vpp# show nat64 prefix
963 * 2001:db8::/32 tenant-vrf 0
964 * 2001:db8:122:300::/56 tenant-vrf 10
967 VLIB_CLI_COMMAND (show_nat64_prefix_command, static) = {
968 .path = "show nat64 prefix",
969 .short_help = "show nat64 prefix",
970 .function = nat64_show_prefix_command_fn,
975 * @cliexstart{nat64 add interface address}
976 * Add/delete NAT64 pool address from specific (DHCP addressed) interface.
977 * To add NAT64 pool address from specific interface use:
978 * vpp# nat64 add interface address GigabitEthernet0/8/0
981 VLIB_CLI_COMMAND (nat64_add_interface_address_command, static) = {
982 .path = "nat64 add interface address",
983 .short_help = "nat64 add interface address <interface> [del]",
984 .function = nat64_add_interface_address_command_fn,
989 * fd.io coding-style-patch-verification: ON
992 * eval: (c-set-style "gnu")