Adding static routes to the Linksys WRT54G
Static routes are stored in a NVRAM variable called static_route. This NVRAM variable is a blank-delimited list of static route entries. Each entry has the following format:
SUBNET_ADDRESS:SUBNET_MASK:GATEWAY:METRIC:INTERFACE
- SUBNET_ADDRESS is the IP subnet address, calculated by applying the netmask to the gateway address, for example.
- SUBNET_MASK is the subnet mask used to disguise which part, of a given IP address, corresponds to the subnet and which part correspond to the host.
- GATEWAY is the IP address of the gateway used to reach the subnet.
- METRIC is the route metric. Routes to the same destination with lower metrics are preferred over those with higher metrics. So, this is usually set to 1 for single-path routes.
- INTERFACE is the interface name used to reach the GATEWAY. Usually it is not needed, as this can be disguised from the current routing table, but the WRT54G implementation of static routes requires this. It is usually vlan0 for LAN-reachable gateways.
During the next boot, the /etc/init.d/S40network initscript will read the static_route NVRAM variable and will inject static entries into the routing table derived from it.
Leave a Reply