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 <nat/nat64.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 (nat_interface_is_inside (i)
272 && nat_interface_is_outside (i)) ? "in out" :
273 nat_interface_is_inside (i) ? "in" : "out");
277 static clib_error_t *
278 nat64_show_interfaces_command_fn (vlib_main_t * vm,
280 input, vlib_cli_command_t * cmd)
282 nat64_main_t *nm = &nat64_main;
285 return clib_error_return (0,
286 "NAT64 disabled, multi thread not supported");
288 vlib_cli_output (vm, "NAT64 interfaces:");
289 nat64_interfaces_walk (nat64_cli_interface_walk, vm);
294 static clib_error_t *
295 nat64_add_del_static_bib_command_fn (vlib_main_t *
298 * input, vlib_cli_command_t * cmd)
300 nat64_main_t *nm = &nat64_main;
301 unformat_input_t _line_input, *line_input = &_line_input;
302 clib_error_t *error = 0;
304 ip6_address_t in_addr;
305 ip4_address_t out_addr;
308 u32 vrf_id = 0, protocol;
309 snat_protocol_t proto = 0;
314 return clib_error_return (0,
315 "NAT64 disabled, multi thread not supported");
317 if (!unformat_user (input, unformat_line_input, line_input))
320 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
322 if (unformat (line_input, "%U %u", unformat_ip6_address,
325 else if (unformat (line_input, "%U %u", unformat_ip4_address,
326 &out_addr, &out_port))
328 else if (unformat (line_input, "vrf %u", &vrf_id))
330 else if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
334 (line_input, "%U %U %u", unformat_ip6_address, &in_addr,
335 unformat_ip4_address, &out_addr, &protocol))
337 else if (unformat (line_input, "del"))
341 error = clib_error_return (0, "unknown input: '%U'",
342 format_unformat_error, line_input);
352 clib_error_return (0, "inside port and address must be set");
359 clib_error_return (0, "outside port and address must be set");
363 p = snat_proto_to_ip_proto (proto);
367 nat64_add_del_static_bib_entry (&in_addr, &out_addr, (u16) in_port,
368 (u16) out_port, p, vrf_id, is_add);
372 case VNET_API_ERROR_NO_SUCH_ENTRY:
373 error = clib_error_return (0, "NAT64 BIB entry not exist.");
375 case VNET_API_ERROR_VALUE_EXIST:
376 error = clib_error_return (0, "NAT64 BIB entry exist.");
378 case VNET_API_ERROR_UNSPECIFIED:
379 error = clib_error_return (0, "Crerate NAT64 BIB entry failed.");
381 case VNET_API_ERROR_INVALID_VALUE:
383 clib_error_return (0, "Outside addres %U and port %u already in use.",
384 format_ip4_address, &out_addr, out_port);
391 unformat_free (line_input);
397 nat64_cli_bib_walk (nat64_db_bib_entry_t * bibe, void *ctx)
399 vlib_main_t *vm = ctx;
402 fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
408 case IP_PROTOCOL_ICMP:
409 case IP_PROTOCOL_TCP:
410 case IP_PROTOCOL_UDP:
411 vlib_cli_output (vm, " %U %u %U %u protocol %U vrf %u %s %u sessions",
412 format_ip6_address, &bibe->in_addr,
413 clib_net_to_host_u16 (bibe->in_port),
414 format_ip4_address, &bibe->out_addr,
415 clib_net_to_host_u16 (bibe->out_port),
416 format_snat_protocol,
417 ip_proto_to_snat_proto (bibe->proto), fib->ft_table_id,
418 bibe->is_static ? "static" : "dynamic", bibe->ses_num);
421 vlib_cli_output (vm, " %U %U protocol %u vrf %u %s %u sessions",
422 format_ip6_address, &bibe->in_addr,
423 format_ip4_address, &bibe->out_addr,
424 bibe->proto, fib->ft_table_id,
425 bibe->is_static ? "static" : "dynamic", bibe->ses_num);
430 static clib_error_t *
431 nat64_show_bib_command_fn (vlib_main_t * vm,
432 unformat_input_t * input, vlib_cli_command_t * cmd)
434 nat64_main_t *nm = &nat64_main;
435 unformat_input_t _line_input, *line_input = &_line_input;
436 clib_error_t *error = 0;
441 return clib_error_return (0,
442 "NAT64 disabled, multi thread not supported");
444 if (!unformat_user (input, unformat_line_input, line_input))
447 if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
448 p = snat_proto_to_ip_proto (proto);
449 else if (unformat (line_input, "unknown"))
451 else if (unformat (line_input, "all"))
455 error = clib_error_return (0, "unknown input: '%U'",
456 format_unformat_error, line_input);
461 vlib_cli_output (vm, "NAT64 BIB entries:");
463 vlib_cli_output (vm, "NAT64 %U BIB entries:", format_snat_protocol,
465 nat64_db_bib_walk (&nm->db, p, nat64_cli_bib_walk, vm);
468 unformat_free (line_input);
473 static clib_error_t *
474 nat64_set_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input,
475 vlib_cli_command_t * cmd)
477 nat64_main_t *nm = &nat64_main;
478 unformat_input_t _line_input, *line_input = &_line_input;
479 clib_error_t *error = 0;
480 u32 timeout, tcp_trans, tcp_est, tcp_incoming_syn;
482 tcp_trans = nat64_get_tcp_trans_timeout ();
483 tcp_est = nat64_get_tcp_est_timeout ();
484 tcp_incoming_syn = nat64_get_tcp_incoming_syn_timeout ();
487 return clib_error_return (0,
488 "NAT64 disabled, multi thread not supported");
490 if (!unformat_user (input, unformat_line_input, line_input))
493 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
495 if (unformat (line_input, "udp %u", &timeout))
497 if (nat64_set_udp_timeout (timeout))
499 error = clib_error_return (0, "Invalid UDP timeout value");
503 else if (unformat (line_input, "icmp %u", &timeout))
505 if (nat64_set_icmp_timeout (timeout))
507 error = clib_error_return (0, "Invalid ICMP timeout value");
511 else if (unformat (line_input, "tcp-trans %u", &tcp_trans))
513 if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
516 clib_error_return (0,
517 "Invalid TCP transitory timeouts value");
521 else if (unformat (line_input, "tcp-est %u", &tcp_est))
523 if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
526 clib_error_return (0,
527 "Invalid TCP established timeouts value");
532 if (unformat (line_input, "tcp-incoming-syn %u", &tcp_incoming_syn))
534 if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn))
537 clib_error_return (0,
538 "Invalid TCP incoming SYN timeouts value");
542 else if (unformat (line_input, "reset"))
544 nat64_set_udp_timeout (0);
545 nat64_set_icmp_timeout (0);
546 nat64_set_tcp_timeouts (0, 0, 0);
550 error = clib_error_return (0, "unknown input '%U'",
551 format_unformat_error, line_input);
557 unformat_free (line_input);
562 static clib_error_t *
563 nat64_show_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input,
564 vlib_cli_command_t * cmd)
566 nat64_main_t *nm = &nat64_main;
569 return clib_error_return (0,
570 "NAT64 disabled, multi thread not supported");
572 vlib_cli_output (vm, "NAT64 session timeouts:");
573 vlib_cli_output (vm, " UDP %usec", nat64_get_udp_timeout ());
574 vlib_cli_output (vm, " ICMP %usec", nat64_get_icmp_timeout ());
575 vlib_cli_output (vm, " TCP transitory %usec",
576 nat64_get_tcp_trans_timeout ());
577 vlib_cli_output (vm, " TCP established %usec",
578 nat64_get_tcp_est_timeout ());
579 vlib_cli_output (vm, " TCP incoming SYN %usec",
580 nat64_get_tcp_incoming_syn_timeout ());
586 nat64_cli_st_walk (nat64_db_st_entry_t * ste, void *ctx)
588 vlib_main_t *vm = ctx;
589 nat64_main_t *nm = &nat64_main;
590 nat64_db_bib_entry_t *bibe;
593 bibe = nat64_db_bib_entry_by_index (&nm->db, ste->proto, ste->bibe_index);
597 fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
601 u32 vrf_id = fib->ft_table_id;
603 if (ste->proto == IP_PROTOCOL_ICMP)
604 vlib_cli_output (vm, " %U %U %u %U %U %u protocol %U vrf %u",
605 format_ip6_address, &bibe->in_addr,
606 format_ip6_address, &ste->in_r_addr,
607 clib_net_to_host_u16 (bibe->in_port),
608 format_ip4_address, &bibe->out_addr,
609 format_ip4_address, &ste->out_r_addr,
610 clib_net_to_host_u16 (bibe->out_port),
611 format_snat_protocol,
612 ip_proto_to_snat_proto (bibe->proto), vrf_id);
613 else if (ste->proto == IP_PROTOCOL_TCP || ste->proto == IP_PROTOCOL_UDP)
614 vlib_cli_output (vm, " %U %u %U %u %U %u %U %u protcol %U vrf %u",
615 format_ip6_address, &bibe->in_addr,
616 clib_net_to_host_u16 (bibe->in_port),
617 format_ip6_address, &ste->in_r_addr,
618 clib_net_to_host_u16 (ste->r_port),
619 format_ip4_address, &bibe->out_addr,
620 clib_net_to_host_u16 (bibe->out_port),
621 format_ip4_address, &ste->out_r_addr,
622 clib_net_to_host_u16 (ste->r_port),
623 format_snat_protocol,
624 ip_proto_to_snat_proto (bibe->proto), vrf_id);
626 vlib_cli_output (vm, " %U %U %U %U protocol %u vrf %u",
627 format_ip6_address, &bibe->in_addr,
628 format_ip6_address, &ste->in_r_addr,
629 format_ip4_address, &bibe->out_addr,
630 format_ip4_address, &ste->out_r_addr,
631 bibe->proto, vrf_id);
636 static clib_error_t *
637 nat64_show_st_command_fn (vlib_main_t * vm,
638 unformat_input_t * input, vlib_cli_command_t * cmd)
640 nat64_main_t *nm = &nat64_main;
641 unformat_input_t _line_input, *line_input = &_line_input;
642 clib_error_t *error = 0;
647 return clib_error_return (0,
648 "NAT64 disabled, multi thread not supported");
650 if (!unformat_user (input, unformat_line_input, line_input))
653 if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
654 p = snat_proto_to_ip_proto (proto);
655 else if (unformat (line_input, "unknown"))
657 else if (unformat (line_input, "all"))
661 error = clib_error_return (0, "unknown input: '%U'",
662 format_unformat_error, line_input);
667 vlib_cli_output (vm, "NAT64 sessions:");
669 vlib_cli_output (vm, "NAT64 %U sessions:", format_snat_protocol, proto);
670 nat64_db_st_walk (&nm->db, p, nat64_cli_st_walk, vm);
673 unformat_free (line_input);
678 static clib_error_t *
679 nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
680 vlib_cli_command_t * cmd)
682 nat64_main_t *nm = &nat64_main;
683 clib_error_t *error = 0;
684 unformat_input_t _line_input, *line_input = &_line_input;
687 ip6_address_t prefix;
692 return clib_error_return (0,
693 "NAT64 disabled, multi thread not supported");
695 if (!unformat_user (input, unformat_line_input, line_input))
698 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
701 (line_input, "%U/%u", unformat_ip6_address, &prefix, &plen))
703 else if (unformat (line_input, "tenant-vrf %u", &vrf_id))
705 else if (unformat (line_input, "del"))
709 error = clib_error_return (0, "unknown input: '%U'",
710 format_unformat_error, line_input);
717 error = clib_error_return (0, "NAT64 prefix must be set.");
721 rv = nat64_add_del_prefix (&prefix, (u8) plen, vrf_id, is_add);
725 case VNET_API_ERROR_NO_SUCH_ENTRY:
726 error = clib_error_return (0, "NAT64 prefix not exist.");
728 case VNET_API_ERROR_INVALID_VALUE:
729 error = clib_error_return (0, "Invalid prefix length.");
736 unformat_free (line_input);
742 nat64_cli_prefix_walk (nat64_prefix_t * p, void *ctx)
744 vlib_main_t *vm = ctx;
746 vlib_cli_output (vm, " %U/%u tenant-vrf %u",
747 format_ip6_address, &p->prefix, p->plen, p->vrf_id);
752 static clib_error_t *
753 nat64_show_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
754 vlib_cli_command_t * cmd)
756 nat64_main_t *nm = &nat64_main;
759 return clib_error_return (0,
760 "NAT64 disabled, multi thread not supported");
762 vlib_cli_output (vm, "NAT64 prefix:");
763 nat64_prefix_walk (nat64_cli_prefix_walk, vm);
772 * @cliexstart{nat64 add pool address}
773 * Add/delete NAT64 pool address.
774 * To add single NAT64 pool address use:
775 * vpp# nat64 add pool address 10.1.1.10
776 * To add NAT64 pool address range use:
777 * vpp# nat64 add pool address 10.1.1.2 - 10.1.1.5
778 * To add NAT64 pool address for specific tenant use:
779 * vpp# nat64 add pool address 10.1.1.100 tenant-vrf 100
782 VLIB_CLI_COMMAND (nat64_add_pool_address_command, static) = {
783 .path = "nat64 add pool address",
784 .short_help = "nat64 add pool address <ip4-range-start> [- <ip4-range-end>] "
785 "[tenant-vrf <vrf-id>] [del]",
786 .function = nat64_add_del_pool_addr_command_fn,
791 * @cliexstart{show nat64 pool}
793 * vpp# show nat64 pool
795 * 10.1.1.3 tenant VRF: 0
796 * 10.1.1.10 tenant VRF: 10
799 VLIB_CLI_COMMAND (show_nat64_pool_command, static) = {
800 .path = "show nat64 pool",
801 .short_help = "show nat64 pool",
802 .function = nat64_show_pool_command_fn,
807 * @cliexstart{set interface nat64}
808 * Enable/disable NAT64 feature on the interface.
809 * To enable NAT64 feature with local (IPv6) network interface
810 * GigabitEthernet0/8/0 and external (IPv4) network interface
811 * GigabitEthernet0/a/0 use:
812 * vpp# set interface nat64 in GigabitEthernet0/8/0 out GigabitEthernet0/a/0
815 VLIB_CLI_COMMAND (set_interface_nat64_command, static) = {
816 .path = "set interface nat64",
817 .short_help = "set interface nat64 in|out <intfc> [del]",
818 .function = nat64_interface_feature_command_fn,
823 * @cliexstart{show nat64 interfaces}
824 * Show interfaces with NAT64 feature.
825 * To show interfaces with NAT64 feature use:
826 * vpp# show nat64 interfaces
828 * GigabitEthernet0/8/0 in
829 * GigabitEthernet0/a/0 out
832 VLIB_CLI_COMMAND (show_nat64_interfaces_command, static) = {
833 .path = "show nat64 interfaces",
834 .short_help = "show nat64 interfaces",
835 .function = nat64_show_interfaces_command_fn,
840 * @cliexstart{nat64 add static bib}
841 * Add/delete NAT64 static BIB entry.
842 * To create NAT64 satatic BIB entry use:
843 * vpp# nat64 add static bib 2001:db8:c000:221:: 1234 10.1.1.3 5678 tcp
844 * vpp# nat64 add static bib 2001:db8:c000:221:: 1234 10.1.1.3 5678 udp vrf 10
847 VLIB_CLI_COMMAND (nat64_add_del_static_bib_command, static) = {
848 .path = "nat64 add static bib",
849 .short_help = "nat64 add static bib <ip6-addr> <port> <ip4-addr> <port> "
850 "tcp|udp|icmp [vfr <table-id>] [del]",
851 .function = nat64_add_del_static_bib_command_fn,
856 * @cliexstart{show nat64 bib}
857 * Show NAT64 BIB entries.
858 * To show NAT64 TCP BIB entries use:
859 * vpp# show nat64 bib tcp
861 * fd01:1::2 6303 10.0.0.3 62303 tcp vrf 0 dynamic 1 sessions
862 * 2001:db8:c000:221:: 1234 10.1.1.3 5678 tcp vrf 0 static 2 sessions
863 * To show NAT64 UDP BIB entries use:
864 * vpp# show nat64 bib udp
866 * fd01:1::2 6304 10.0.0.3 10546 udp vrf 0 dynamic 10 sessions
867 * 2001:db8:c000:221:: 1234 10.1.1.3 5678 udp vrf 10 static 0 sessions
868 * To show NAT64 ICMP BIB entries use:
869 * vpp# show nat64 bib icmp
871 * fd01:1::2 6305 10.0.0.3 63209 icmp vrf 10 dynamic 1 sessions
874 VLIB_CLI_COMMAND (show_nat64_bib_command, static) = {
875 .path = "show nat64 bib",
876 .short_help = "show nat64 bib all|tcp|udp|icmp|unknown",
877 .function = nat64_show_bib_command_fn,
882 * @cliexstart{set nat64 timeouts}
883 * Set NAT64 session timeouts (in seconds).
884 * To set NAT64 session timeoutes use use:
885 * vpp# set nat64 timeouts udp 200 icmp 30 tcp-trans 250 tcp-est 7450
886 * To reset NAT64 session timeoutes to default values use:
887 * vpp# set nat64 timeouts reset
890 VLIB_CLI_COMMAND (set_nat64_timeouts_command, static) = {
891 .path = "set nat64 timeouts",
892 .short_help = "set nat64 timeouts udp <sec> icmp <sec> tcp-trans <sec> "
893 "tcp-est <sec> tcp-incoming-syn <sec> | reset",
894 .function = nat64_set_timeouts_command_fn,
899 * @cliexstart{show nat64 timeoutss}
900 * Show NAT64 session timeouts:
901 * vpp# show nat64 timeouts
902 * NAT64 session timeouts:
905 * TCP transitory 240sec
906 * TCP established 7440sec
907 * TCP incoming SYN 6sec
910 VLIB_CLI_COMMAND (show_nat64_timeouts_command, static) = {
911 .path = "show nat64 timeouts",
912 .short_help = "show nat64 timeouts",
913 .function = nat64_show_timeouts_command_fn,
918 * @cliexstart{show nat64 session table}
919 * Show NAT64 session table.
920 * To show NAT64 TCP session table use:
921 * vpp# show nat64 session table tcp
922 * NAT64 tcp session table:
923 * fd01:1::2 6303 64:ff9b::ac10:202 20 10.0.0.3 62303 172.16.2.2 20 tcp vrf 0
924 * fd01:3::2 6303 64:ff9b::ac10:202 20 10.0.10.3 21300 172.16.2.2 20 tcp vrf 10
925 * To show NAT64 UDP session table use:
926 * #vpp show nat64 session table udp
927 * NAT64 udp session table:
928 * fd01:1::2 6304 64:ff9b::ac10:202 20 10.0.0.3 10546 172.16.2.2 20 udp vrf 0
929 * fd01:3::2 6304 64:ff9b::ac10:202 20 10.0.10.3 58627 172.16.2.2 20 udp vrf 10
930 * fd01:1::2 1235 64:ff9b::a00:3 4023 10.0.0.3 24488 10.0.0.3 4023 udp vrf 0
931 * fd01:1::3 23 64:ff9b::a00:3 24488 10.0.0.3 4023 10.0.0.3 24488 udp vrf 0
932 * To show NAT64 ICMP session table use:
933 * #vpp show nat64 session table icmp
934 * NAT64 icmp session table:
935 * fd01:1::2 64:ff9b::ac10:202 6305 10.0.0.3 172.16.2.2 63209 icmp vrf 0
938 VLIB_CLI_COMMAND (show_nat64_st_command, static) = {
939 .path = "show nat64 session table",
940 .short_help = "show nat64 session table all|tcp|udp|icmp|unknown",
941 .function = nat64_show_st_command_fn,
946 * @cliexstart{nat64 add prefix}
947 * Set NAT64 prefix for generating IPv6 representations of IPv4 addresses.
948 * To set NAT64 global prefix use:
949 * vpp# nat64 add prefix 2001:db8::/32
950 * To set NAT64 prefix for specific tenant use:
951 * vpp# nat64 add prefix 2001:db8:122:300::/56 tenant-vrf 10
954 VLIB_CLI_COMMAND (nat64_add_del_prefix_command, static) = {
955 .path = "nat64 add prefix",
956 .short_help = "nat64 add prefix <ip6-prefix>/<plen> [tenant-vrf <vrf-id>] "
958 .function = nat64_add_del_prefix_command_fn,
963 * @cliexstart{show nat64 prefix}
965 * To show NAT64 prefix use:
966 * vpp# show nat64 prefix
968 * 2001:db8::/32 tenant-vrf 0
969 * 2001:db8:122:300::/56 tenant-vrf 10
972 VLIB_CLI_COMMAND (show_nat64_prefix_command, static) = {
973 .path = "show nat64 prefix",
974 .short_help = "show nat64 prefix",
975 .function = nat64_show_prefix_command_fn,
981 * fd.io coding-style-patch-verification: ON
984 * eval: (c-set-style "gnu")