howto:general:routing:static_routing

Static routing

Static routes provides additional routing information to your router.

Overview

Level of difficulty

 Easy

Use-case

Static routes can be used to route connections to a specific host or address trough a specific interface, which may be a VPN-Connection.

All requests to dd-wrt.com should be routed through a given gateway.

Static-Route properties
interface wan
target 83.141.4.210 (dd-wrt.com)
netmask 255.255.255.255
gateway 172.27.0.1

Instructions

GUI

Not available, yet

UCI Config System

  • Add static route section
uci add network route                                         
uci set network.@route[-1].interface=wan                      
uci set network.@route[-1].target=84.141.4.210                
uci set network.@route[-1].netmask=255.255.255.255            
uci set network.@route[-1].gateway=172.27.0.1                 
  • Store changes
uci commit network
  • Apply changes
/etc/init.d/network reload

UCI config files (native)

Routes are defined in /etc/config/network

  • Add new rule-section
config 'route'                                                                  
        option interface 'wan'                                                
        option target '83.141.4.210'                                          
        option netmask '255.255.255.255'                                      
        option gateway '172.27.0.1' 
  • Restart service
/etc/init.d/network reload

Troubleshooting

You can check if the route has been applied successful by looking at the routing table with the route command

# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         172.27.0.1      0.0.0.0         UG    0      0        0 eth1
84.141.4.210    172.27.0.1      255.255.255.255 UGH   0      0        0 eth1
172.27.0.0      *               255.255.255.0   U     0      0        0 eth1
192.168.1.0     *               255.255.255.0   U     0      0        0 br-lan

The field 'Destination' should match the target from the UCI configuration, Gateway matches Gateway, and the Iface should match the actual interface name.

howto/general/routing/static_routing.txt · Last modified: 2018/05/24 09:05 (external edit)