This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
howto:general:routing:static_routing [2015/05/18 10:22] admin [Use-case] |
howto:general:routing:static_routing [2018/05/24 09:05] (current) |
||
|---|---|---|---|
| Line 8: | Line 8: | ||
| Easy | 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 | | ||
| ==== Related topics ==== | ==== Related topics ==== | ||
| * [[documentation:configuration:uci|UCI]] | * [[documentation:configuration:uci|UCI]] | ||
| - | * [[documentation:configuration:config_files:config_files_involved|/etc/config/config_file]] | + | * [[documentation:configuration:config_files:config_network#route|/etc/config/network]] |
| - | + | ||
| ===== Instructions ===== | ===== Instructions ===== | ||
| Line 19: | Line 31: | ||
| Not available, yet | Not available, yet | ||
| + | |||
| ==== UCI Config System ==== | ==== UCI Config System ==== | ||
| - | * **Add something** | + | * **Add static route section** |
| <code> | <code> | ||
| - | ... | + | 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 | ||
| </code> | </code> | ||
| * **Store changes** | * **Store changes** | ||
| <code> | <code> | ||
| - | uci commit xxx | + | uci commit network |
| </code> | </code> | ||
| * **Apply changes** | * **Apply changes** | ||
| <code> | <code> | ||
| - | /etc/init.d/xxx restart | + | /etc/init.d/network reload |
| </code> | </code> | ||
| ==== UCI config files (native) ==== | ==== UCI config files (native) ==== | ||
| - | Feature is defined in [[documentation:configuration:config_files:config_file_involved|/etc/config/config_file]] | + | Routes are defined in [[documentation:configuration:config_files:config_network|/etc/config/network]] |
| - | * **New something** | + | * **Add new rule-section** |
| <code> | <code> | ||
| - | config 'something' | + | config 'route' |
| - | option 'name' 'whatever' | + | option interface 'wan' |
| - | | + | option target '83.141.4.210' |
| + | option netmask '255.255.255.255' | ||
| + | option gateway '172.27.0.1' | ||
| </code> | </code> | ||
| + | * **Restart service** | ||
| + | <code> | ||
| + | /etc/init.d/network reload | ||
| + | </code> | ||
| ===== Troubleshooting ===== | ===== Troubleshooting ===== | ||
| - | Not available, yet | + | You can check if the route has been applied successful by looking at the routing table with the **route** command |
| + | <code> | ||
| + | # 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 | ||
| + | </code> | ||
| + | The field 'Destination' should match the target from the UCI configuration, | ||
| + | Gateway matches Gateway, and the Iface should match the actual interface name. | ||