Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:dpi:dpi_options:router:start [2021/08/02 11:14] – edrudichgmailcom | en:dpi:dpi_options:router:start [2022/03/29 13:29] (current) – removed edrudichgmailcom | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== 20 Router ====== | ||
- | {{indexmenu_n> | ||
- | <note warning> | ||
- | <note important> | ||
- | |||
- | < | ||
- | | ||
- | ===== General Description ===== | ||
- | Stingray Service Gateway (SSG) itself does not build the routing table. It delegates this work to proven specialised tools. The example uses the BIRD root daemon. The router daemon processes the required routing protocols (BGP, OSPF, etc.) and uses them to build a common routing table which it loads into the kernel. SSG performs routing of packets using this table. | ||
- | {{ : | ||
- | <note tip> | ||
- | Instead of BIRD, any other daemon that builds a routing table in the Linux kernel can be used, such as [[https:// | ||
- | In future versions, in order to save memory, it is possible to introduce optional specialized APIs for communication with a particular daemon to bypass kernel route table construction and communicate with the daemon directly.</ | ||
- | |||
- | Since BIRD builds the routing table in the OS kernel, to avoid application of these rules by the Linux server itself, the BIRD root daemon runs in a separate net namespace (in the diagram it is '' | ||
- | |||
- | ==== The Internal Router Architecture ==== | ||
- | Data from the kernel route table is read (rtnetlink) in the router' | ||
- | |||
- | The worker threads use FIB. This structure is designed for multi-threaded search (LPM - longest prefix match), but is not designed for modifications (deletion/ | ||
- | |||
- | ===== System Requirements ===== | ||
- | Router mode in SSG requires quite a lot of memory, especially with BGP full view. Plus, memory is required for the BIRD daemon that builds the routing table via BGP, OSPF, etc. Router mode (especially BGP full view) requires at least 4-8G additional memory. | ||
- | |||
- | ===== Setting veth-nterface Names ===== | ||
- | The fastdpi.conf describes all TAP-interfaces associated with the devices: | ||
- | < | ||
- | # Description of one router interface | ||
- | # WARNING! ' | ||
- | router_device { | ||
- | # Device name from in_dev/ | ||
- | device= | ||
- | # TAP interface name for the device (default=' | ||
- | #tap= | ||
- | # Name of the paired TAP interface in netns for the device (default=' | ||
- | #peer= | ||
- | # WARNING! ' | ||
- | } | ||
- | </ | ||
- | |||
- | For example, for this configuration | ||
- | < | ||
- | in_dev=41-00.0 | ||
- | out_dev=41-00.1 | ||
- | </ | ||
- | where only '' | ||
- | < | ||
- | in_dev=41-00.0 | ||
- | out_dev=41-00.1 | ||
- | |||
- | router_device { | ||
- | # Device name from in_dev/ | ||
- | device=41-00.1 | ||
- | # TAP interface name for the device (default=' | ||
- | tap=tap41 | ||
- | # Name of the paired TAP interface in netns for the device (default=' | ||
- | peer=bgp41 | ||
- | } | ||
- | </ | ||
- | |||
- | It is possible not to specify the names of the '' | ||
- | < | ||
- | in_dev=41-00.0 | ||
- | out_dev=41-00.1 | ||
- | |||
- | # TAP for out_dev: | ||
- | router_device { | ||
- | device=41-00.1 | ||
- | } | ||
- | |||
- | # TAP for in_dev | ||
- | router_device { | ||
- | device=41-00.0 | ||
- | } | ||
- | </ | ||
- | In this case the TAP interface names are assumed to be as follows: | ||
- | * for '' | ||
- | * for '' | ||
- | |||
- | ===== TAP Subnets Configuration ===== | ||
- | For each '' | ||
- | |||
- | Subnets are defined by the '' | ||
- | For example, the following configuration | ||
- | < | ||
- | router_device { | ||
- | # Device name from in_dev/ | ||
- | device=41-00.1 | ||
- | # TAP interface name for the device (default=' | ||
- | tap=tap41 | ||
- | # Name of the paired TAP interface in netns for the device (default=' | ||
- | peer=bgp41 | ||
- | |||
- | # Which IPv4 subnets to allocate to TAP | ||
- | subnet=10.0.2.0/ | ||
- | subnet=8.8.8.0/ | ||
- | |||
- | # Which IPv6 subnets to allocate to TAP | ||
- | subnet6=2001:: | ||
- | # link-local the address of the interface with which bird communicates | ||
- | subnet6=fe80:: | ||
- | } | ||
- | </ | ||
- | specifies two IPv4 subnets for device '' | ||
- | |||
- | <note important> | ||
- | |||
- | OSPF uses the multicast addresses 224.0.0.5 and 224.0.0.6, so if the '' | ||
- | < | ||
- | router_device { | ||
- | device=41-00.1 | ||
- | tap=tap41 | ||
- | peer=bgp41 | ||
- | |||
- | # OSPF multicast | ||
- | subnet=224.0.0.5/ | ||
- | subnet=224.0.0.6/ | ||
- | } | ||
- | </ | ||
- | |||
- | <note warning> | ||
- | |||
- | ===== Creating veth interfaces ===== | ||
- | <note important> | ||
- | |||
- | Suppose we have the following devices specified in fastdpi.conf: | ||
- | < | ||
- | in_dev=41-00.0 | ||
- | out_dev=41-00.1 | ||
- | </ | ||
- | Suppose we need to configure the BGP protocol for uplink in BIRD, i.e. on the '' | ||
- | <note tip> | ||
- | To redirect BGP traffic from '' | ||
- | |||
- | Create '' | ||
- | < | ||
- | ip netns add bird | ||
- | </ | ||
- | |||
- | Create the veth pair: | ||
- | < | ||
- | ip link add dpi41-00.1 type veth peer name rib41-00.1 netns bird | ||
- | </ | ||
- | |||
- | The rib interface must have an IP address (and IPv6 if IPv6 is supported). This address will be the BGP peer address for the BGP neighbour. | ||
- | < | ||
- | ip netns exec bird ip address add 10.0.0.4/24 broadcast 10.0.0.255 dev rib41-00.1 | ||
- | ip netns exec bird ip address add 2098::4/124 dev rib41-00.1 | ||
- | # enable ARP on the interface | ||
- | ip netns exec bird ip link set dev rib41-00.1 arp on | ||
- | |||
- | # set tx checksum offload off - turn off checksum calculation on the interface | ||
- | # noticed that the CRC calculation on the interface may not be correct (at least on some CentOS-8 kernel builds) | ||
- | ip netns exec bird ethtool -K rib41-00.1 tx off | ||
- | </ | ||
- | <note warning> | ||
- | |||
- | The dpi interface **should have neither IPv4 nor IPv6 addresses**, | ||
- | < | ||
- | ip link set dev dpi41-00.1 arp off | ||
- | # Disable IPv6 on dpiXXX interfaces (so that there is not even a link-local address) | ||
- | echo 1>/ | ||
- | </ | ||
- | |||
- | Finally, bring up all created interfaces: | ||
- | < | ||
- | ip link set dpi41-00.1 up | ||
- | ip netns exec bird ip link set lo up | ||
- | ip netns exec bird ip link set rib41-00.1 up | ||
- | </ | ||
- | |||
- | Do not forget the firewall: | ||
- | < | ||
- | firewall-cmd --zone=internal --add-source=10.0.0.1/ | ||
- | firewall-cmd --zone=internal --add-rich-rule=' | ||
- | </ | ||
- | |||
- | Remember that BIRD must be run in '' | ||
- | < | ||
- | ip netns exec bird / | ||
- | </ | ||
- | |||
- | <note important> | ||
- | |||
- | < | ||
- | SSG sends packets to the rib interfaces "as is" without any conversion. It means that if you have a VLAN, you have to use Linux to create vlan interfaces on the rib interface and bind the bird to those vlan interfaces.\\ | ||
- | In fastdpi.conf vlan interfaces created on a rib interface must not be listed anywhere - you must specify the two ends of the veth pair as '' | ||
- | |||
- | < | ||
- | SSG **does not set** the MTU on the veth interfaces. When configuring the veth interfaces, the MTU must be set using the standard Linux tools. | ||
- | </ | ||
- | |||
- | ===== LAG Support ===== | ||
- | Stingray Service Gateway 10.1 adds support for link aggregation in the router. | ||
- | |||
- | For aggregated channels, packets that need to be diverted to a TAP interface can go to any device that is part of a LAG. To avoid creating the same TAP interface for each device in a LAG, the router takes into account which devices are included in the LAG and for all such devices does a diversion of traffic of the specified subnets to the TAP (to the BIRD daemon). | ||
- | |||
- | Each LAG is defined by a separate section in fastdpi.conf which lists all the devices included in the LAG: | ||
- | < | ||
- | # In/out devices, combined in a LAG | ||
- | in_dev=01-00.0: | ||
- | out_dev=01-00.1: | ||
- | |||
- | # Describing the LAG towards the inet | ||
- | lag { | ||
- | # Optional LAG name, used only for log output | ||
- | name=inet | ||
- | # Each device included in a LAG is described by a separate device parameter | ||
- | device=01-00.1 | ||
- | device=02-00.1 | ||
- | } | ||
- | |||
- | # Description of one router interface | ||
- | router_device { | ||
- | # Device name from out_dev. Only for this device create a veth pair of TAP interfaces | ||
- | device=01-00.1 | ||
- | # TAP interface name for the device (default=' | ||
- | tap=tap0 | ||
- | # Name of the paired TAP interface in netns for the device (default=' | ||
- | peer=peer0 | ||
- | # Subnets diverted from total traffic to the TAP device (example) | ||
- | subnet=10.0.10.0/ | ||
- | #...other subnets... | ||
- | } | ||
- | </ | ||
- | With this description, | ||
- | |||
- | The '' | ||
- | If the router works both inet and subs direction (e.g. BGP on the inet side and OSPF inside the network, subs side), two '' | ||
- | < | ||
- | # LAG towards inet | ||
- | lag { | ||
- | name=inet | ||
- | device=01-00.1 | ||
- | device=02-00.1 | ||
- | } | ||
- | |||
- | # LAG towards subs | ||
- | lag { | ||
- | name=subs | ||
- | device=01-00.0 | ||
- | device=02-00.0 | ||
- | } | ||
- | </ | ||
- | and a separate '' | ||
- | |||
- | A maximum of 10 different lag sections can be configured in total. | ||
- | |||
- | <note tip>The '' | ||
- | |||
- | ===== Multi-path routing (ECMP) ===== | ||
- | Support for multi-path routing ([[https:// | ||
- | |||
- | SSG performs traffic balancing (round-robin) at the flow level for all routes from the multi-path. | ||
- | Balancing at the flow level means that a specific flow will be assigned to one of the routes from the multi-path, and the selected route will not change until the end of this flow (unless the composition of the multi-path is changed by external events from the routing daemon). | ||
- | |||
- | No configuration is required to enable multi-path in SSG. ECMP support is enabled in the configuration parameters of the routing daemon. | ||
- | For example, in BIRD, ECMP support is enabled by specifying '' | ||
- | |||
- | ===== Root Daemon Configuration (BIRD, FRR, etc.) ===== | ||
- | **must be consistent**: | ||
- | Supported Routing Daemons: | ||
- | - [[https:// | ||
- | - [[http:// | ||
- | - [[https:// | ||
- | - [[https:// | ||
- | |||
- | |||
- | |||
- | ===== fastDPI Configuration ===== | ||
- | ==== Mandatory parameters ==== | ||
- | To enable the routing function, you need to activate the parameter in fastdpi.conf | ||
- | < | ||
- | # [cold] enabling the router | ||
- | # Boolean parameter: | ||
- | # 0, false, off - router is off (default) | ||
- | # 1, true, on - router is on | ||
- | # Does not allow changes on-the-fly via reload | ||
- | router=1 | ||
- | </ | ||
- | |||
- | Next you need to specify in which netns BIRD runs and the number of the kernel routing table it builds: | ||
- | < | ||
- | # [cold] net namespace in which BIRD is running | ||
- | router_netns=bird | ||
- | # [cold] Number of the kernel routing table that fastDPI uses | ||
- | router_kernel_table=1 | ||
- | </ | ||
- | |||
- | The following BRAS parameters must also be set, even if none of the BRAS modes are enabled: | ||
- | < | ||
- | # Stingray Virtual MAC Address | ||
- | bras_arp_mac=00: | ||
- | |||
- | # Stingray Virtual IP Address | ||
- | bras_arp_ip=188.227.73.40 | ||
- | |||
- | # If IPv6 is used, virtual IPv6 addresses must be set: | ||
- | |||
- | # Sets the global IPv6 address of the Stingray | ||
- | bras_ipv6_address=2098:: | ||
- | |||
- | # Sets the IPv6 link-local address of the Stingray (prefix FE80::/10) | ||
- | # If this parameter is not set explicitly, it is calculated by bras_arp_mac | ||
- | # | ||
- | </ | ||
- | |||
- | <note tip> | ||
- | The other parameters listed below are optional and are for fine-tuning the router in Stingray Service Gateway.</ | ||
- | |||
- | ==== Subscriber announcements and NAT pool ==== | ||
- | Announcing subscriber addresses is enabled by a parameter in fastdpi.conf: | ||
- | < | ||
- | # [cold] Subscriber address announcement flags | ||
- | # Bit mask | ||
- | # Values: | ||
- | # 1 - announce the subscriber' | ||
- | # 2 - announce the subscriber' | ||
- | # 4 - announce NAT subnets towards the inet | ||
- | # 8 - announce subscriber gateways (direction is set by 1 and 2 flags) | ||
- | # Default value: 0 - not to announce anything | ||
- | # | ||
- | |||
- | # [hot] Metric for subscriber address announcements | ||
- | # Default value = 32 | ||
- | # | ||
- | </ | ||
- | {{ : | ||
- | NAT public address subnets are announced only towards the inet when the SSG starts and when adding/ | ||
- | |||
- | {{ : | ||
- | Subscriber addresses can be announced both towards inet and subs side. But if the subscriber' | ||
- | |||
- | ==== Additional parameters ==== | ||
- | The maximum number of routes is set by the parameters: | ||
- | < | ||
- | # [cold] Maximum number of routes in IPv4 route table | ||
- | # Default value = 1000000 | ||
- | # | ||
- | |||
- | # [cold] Maximum number of routes in IPv6 route table | ||
- | # Default value = 200000 | ||
- | # | ||
- | </ | ||
- | When starting in the router mode, SSG preallocates memory for the internal route table in accordance with these parameters. It is recommended to set these options (if necessary) with 20-30% reserve to ensure that the preallocated memory will be enough during the router operation. | ||
- | |||
- | The forwarding information base (FIB) in SSG is updated every '' | ||
- | < | ||
- | # [hot] FIB update period, seconds | ||
- | # Default value - every 15 seconds | ||
- | # | ||
- | </ | ||
- | It makes no sense to set this parameter too small (less than 5 seconds). | ||
- | |||
- | The maximum size of neighbor cache (ARP cache) and the timeout for updating the records of this cache is set by the parameters: | ||
- | < | ||
- | # [cold] Max size of ARP cache (neighbor сache for IPv6) | ||
- | # Default value - 1024, max = 32K | ||
- | # | ||
- | </ | ||
- | The Stingray SG contains separate neighbor caches for IPv4 and IPv6, each of size '' | ||
- | |||
- | The Stingray SG itself does not send ARP requests for obsolete cache entries. Instead, it relies on updates from the Linux kernel: Stingray monitors the ARP responses coming to the TAP-interfaces subnet address, and updates its ARP cache in accordance with these responses. The same applies to IPv6 (monitoring ICMPv6 neighbor discovery). | ||
- | |||
- | The router runs in a separate thread on a separate CPU core. At start Stingray sets parameters of this thread by default, which can be changed by parameters: | ||
- | < | ||
- | # [cold] Adding to the priority of the router' | ||
- | # | ||
- | |||
- | # [cold] Router thread binding kernel, -1 - autodetection | ||
- | # | ||
- | </ | ||
- | Do not change these parameters unless absolutely necessary; it is better to let SSG determine the core and priority itself. For example, explicitly specifying a core for router '' | ||
- | <note warning> | ||
- | |||
- | ===== Special Aspects of addresses announcing ===== | ||
- | |||
- | ====Announcement of L3 subscriber addresses ==== | ||
- | |||
- | В СКАТ 10.2 действует следующий алгоритм анонсов IP-адресов [[dpi: | ||
- | * по умолчанию, | ||
- | * fastdpi.conf-параметр '' | ||
- | < | ||
- | # [hot] Анонсировать (1) или нет (0) неавторизованных (Reject) абонентов | ||
- | # Значение по умолчанию - 0 (не анонсировать) | ||
- | # | ||
- | </ | ||
- | * добавлен новый Радиус-атрибут '' | ||
- | |||
- | Итого при решении вопроса, | ||
- | * если в ответе Радиуса (Accept или Reject) явно задан атрибут '' | ||
- | * если атрибута '' | ||
- | * Для Access-Accept (успешная авторизация) IP-адрес абонента анонсируется | ||
- | * Для Access-Reject (неуспешная авторизация) IP-адрес анонсируется только если fastdpi.conf-параметр '' | ||
- | |||
- | < | ||
- | |||
- | Данный алгоритм также применяется для ARP-авторизации и GTP-авторизации, | ||
- | |||
- | Для прочих видов L2-авторизации (DHCP, PPP, - всех, где явно **выдается** IP-адрес) атрибут '' | ||
- | |||
- | ===== Router Troubleshooting | ||
- | SSG Router for debugging purposes can record traffic from BIRD to pcap: | ||
- | < | ||
- | # [hot] Recording pcap from the router' | ||
- | # Note: You can also record traffic with the tcpdump utility (specify the TAP interface name). | ||
- | # But the problem is that tcpdump does not work with interfaces in DOWN mode, | ||
- | # hat is, tcpdump cannot record traffic | ||
- | # when the interface goes from DOWN to UP. | ||
- | # AP interface names with ';' | ||
- | # For each TAP interface, a separate pcap file named tap_< | ||
- | # in the directory specified by the ajb_udpi_path parameter (by default / | ||
- | # | ||
- | |||
- | # [hot] Direction of packets for pcap recording from TAP interfaces | ||
- | # Values: | ||
- | # 1 - TAP -> inward (packets from the TAP interface) | ||
- | # 2 - outward -> TAP (packets towards the TAP interface) | ||
- | # 0 or 3 - all directions | ||
- | # | ||
- | |||
- | # [hot] TAP pcap rotation interval, seconds | ||
- | # 0 - is taken from the ajb_udpi_ftimeout parameter (ajb_udpi_ftimeout is set in minutes) | ||
- | # | ||
- | </ | ||
- | |||
- | You can also enable recording to pcap the data exchange with the kernel (rtnetlink): | ||
- | < | ||
- | # [hot] To record rtnetlink messages в pcap or not | ||
- | # 0 - recording disabled | ||
- | # 1 - recording enabled | ||
- | # Prefix of pcap files = " | ||
- | # | ||
- | </ | ||
- | |||
- | Moreover, if packets are recorded to pcap by address mask ('' | ||
- | |||
- | ===== CLI commands ===== | ||
- | Stingray has a set of CLI commands to view the current router status. For a complete list of commands see: | ||
- | < | ||
- | fdpi_cli help router | ||
- | </ | ||
- | |||
- | < | ||
- | |||
- | Also keep in mind that the routing table for BGP, OSPF, etc. is built by BIRD, which has its own command line utility '' |