Routing basics

See also: IP Layer Network Administration, IP routing tutorial

Routing is the process of selecting a path to send network traffic. There are several routing protocols for dynamic routing, specifically B.A.T.M.A.N. and OLSR for mesh networking, however static routing is typically enough for most use cases. Routing is handled by a kernel component and can be configured by the user space tool ip from the package iproute2. Note that by default OpenWrt announces IPv6 default route only for GUA and applies source routing for IPv6 that allows routing only for prefixes delegated from the upstream router.

In a trivial case, the route is selected by the traffic destination, highest netmask and lowest metric. Routing rules are expected to be in their default state and can be basically ignored, the same applies to routing tables other than the main table.

In general case, the kernel iterates over the routing rules from lower to higher numerical priority values. The default route is typically in the main table and the corresponding rule is automatically created with a priority of 32766. If we utilize custom routing tables with ip4table or ip6table, netifd creates the rules for each local address as source and each local subnet as destination with respective priorities of 10000 and 20000. To override the default route in the main table, we can add a rule with a priority of about 30000, or assign each upstream interface to a separate routing table and lookup it after the main table.

See also: Static routes, Routing rules

/etc/config/network is the UCI configuration file where all routing related adjustments are made in OpenWrt.

See also: ip-route

ID Name Description
0 unspec Special table matching all table names/IDs.
253 default Reserved table, empty by default.
254 main Routing table with all non-policy routes.
255 local Special table with local and broadcast addresses.

Edit /etc/iproute2/rt_tables to customize routing tables.

See also: ip-rule

Priority Match Lookup table Description
0 anything local High priority routing for local and broadcast addresses.
10000 local addresses as source <custom> A list of rules for each local address created by netifd when using ip4table or ip6table.
20000 local subnets as destination <custom> A list of rules for each local subnet created by netifd when using ip4table or ip6table.
32766 anything main Non-policy routing, can be overridden with other rules by the administrator, also offers routes for tunnel endpoints.
32767 IPv4 traffic default Post-processing for IPv4 traffic missed by previous rules.
90000+ traffic from local system <custom> A list of rules for each interface created by netifd when using ip4table or ip6table, works as failover for traffic from the local system.
4200000000+ IPv6 traffic to interfaces - A list of terminating rules automatically created for each IPv6 interface.

Use traceroute and traceroute6 to verify your traffic is routed via the proper gateway.

traceroute openwrt.org
traceroute6 openwrt.org

Check your public IP addresses.

Make sure there is no DNS leak.

Collect and analyze the following information.

# Restart services
/etc/init.d/log restart; /etc/init.d/network restart; sleep 10
 
# Log and status
logread; ifstatus wan; ifstatus wan6
 
# Runtime configuration
ip address show; ip route show table all
ip rule show; iptables-save -c
ip -6 rule show; ip6tables-save -c
 
# Persistent configuration
uci show network; uci show dhcp; uci show firewall
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2021/10/15 04:11
  • by bobafetthotmail