Static routing: Difference between revisions

Content deleted Content added
m Reverted 1 edit by 202.57.47.196 (talk) to last revision by Nyook (TW)
m fixed lint errors – stripped tags
 
(38 intermediate revisions by 23 users not shown)
Line 1:
{{Short description|Use of fixed routes for routing in networks}}
'''Static routing''' is a form of [[routing]] that occurs when a router uses a manually-configured routing entry, rather than information from a dynamic routing traffic.<ref>[http://www.redbooks.ibm.com/redbooks/pdfs/gg243376.pdf TCP/IP Tutorial and Technical Overview (IBM RedBooks Series)]</ref> In many cases, static routes are manually configured by a [[network administrator]] by adding in entries into a [[routing table]], though this may not always be the case.<ref name=SLA>http://www.cisco.com/c/en/us/td/docs/ios/dial/configuration/guide/12_2sr/dia_12_2sr_book/dia_rel_stc_rtg_bckup.html</ref> Unlike [[dynamic routing]], static routes are fixed and do not change if the network is changed or reconfigured. Static routing and [[dynamic routing]] are not mutually exclusive. Both dynamic routing and static routing are usually used on a router to maximise routing efficiency and to provide backups in the event that dynamic routing information fails to be exchanged. Static routing can also be used in [[stub network]]s, or to provide a [[default route|gateway of last resort]].
 
'''Static routing''' describes a process by which [[routing]] is configured with fixed values that do not change at runtime unless manually edited. Static routes are used with and without dynamic [[routing protocol]]s and usually share the same [[routing table]] as those protocols.<ref>[http://www.redbooks.ibm.com/redbooks/pdfs/gg243376.pdf TCP/IP Tutorial and Technical Overview (IBM RedBooks Series)]</ref> Routes require at least two attributes; the destination and the gateway, but may contain additional attributes such as a [[Metrics (networking)|metric]] (sometimes called the ''administrative distance''). Some implementations treat the network address and [[subnet mask]] as separate values, however in practice both of the values have to be considered for any given routing decision to determine the [[longest prefix match]]. Static routes together with ''connected'' routes and routes from configuration protocols such as [[DHCP]] or [[Neighbor Discovery Protocol|Router Advertisements]] provide the routes which are then redistributed using dynamic routing protocols.<ref>{{Cite web |title=ESPCommunity |url=https://enterprise-support.nvidia.com/s/article/howto-configure-bgp-on-mellanox-switches |access-date=2024-12-18 |website=enterprise-support.nvidia.com}}</ref> While static routes are entered into the system and remain there until removed or changed manually, dynamic routing protocols create and delete routes dynamically at runtime without intervention. Thus the term ''static'' here refers to the nature of remaining unchanged by the system itself. The most prominent example of a static route is a [[default route]] which is often used on devices with a statically configured [[IP address]] to provide the device with access to the rest of the network or the internet by default.<ref>{{Cite web |title=Static Routing {{!}} Cumulus Linux 5.11 |url=https://docs.nvidia.com/networking-ethernet-software/cumulus-linux-511/Layer-3/Routing/Static-Routing/#configure-a-gateway-or-default-route |access-date=2024-12-18 |website=docs.nvidia.com}}</ref> In contrast to a so called ''connected'' route which is automatically generated upon address assignment based on the used subnet mask, a static route must be manually configured. Due to this the configuration may fail if there is no route to the provided gateway at the time of configuration, other than the connected route which will always succeed as it does not require a gateway. The gateway of a static route need not be an address, but can also specify an interface in most implementations.
 
== Uses ==
Static routing may have the following uses:
* When using static address configuration (in the absence of DHCP or Router Advertisements) it can be used to provide a [[default route]], forming a special case of the longest prefix match as it has a prefix length of zero and therefore always matches, and always matches last.
* Static routing can be used to define an exit point from a router when no other routes are available or necessary. This is called a [[default route]].
* In small networks it is a viable method for providing alternative routes to direct traffic when multiple routers exist. This is a simple but limited form of [[teletraffic engineering]].
* Static routing can be used for small networks that require only one or two routes. This is often more efficient since a link is not being wasted by exchanging dynamic routing information.
* Static routing has applications in environments with many routes with infrequent changes as it reduces the delay it would take to synchronize the routes from another device.
* Static routing is often used as a complement to dynamic routing to provide a failsafe backup in the event that a dynamic route is unavailable.
* On heavily resource constrained devices where routing protocols may not be viable due to lack of computation power, static routes may be used instead.
* Static routing is often used to help transfer routing information from one routing protocol to another (routing redistribution).
* Static routes, connected routes, and routes from dynamic configuration protocols can be redistributed by dynamic routing protocols. For instance, a router may have a static or connected route for a local network segment, which is then redistributed over dynamic routing protocols to enable connectivity to that network.<ref>{{Cite web |title=Route Filtering and Redistribution {{!}} Cumulus Linux 5.11 |url=https://docs.nvidia.com/networking-ethernet-software/cumulus-linux-511/Layer-3/Routing/Route-Filtering-and-Redistribution/#route-redistribution |access-date=2024-12-18 |website=docs.nvidia.com}}</ref>
* By using the [[Metrics (networking)|metric]] to reduce the priority of a static route a fallback can be provided for instance when a DHCP server becomes unavailable. This can also prevent a type of lockout situation in which one would be unable to access the device otherwise.
 
== Advantages ==
Static routing, if used without dynamic routing, has the following advantages:{{cn|date=December 2017}}
* Due to being configured on the device it can serve as a bootstrap for other protocols.<ref>{{Cite web |title=Inter-Router Communication > BGP Fundamentals {{!}} Cisco Press |url=https://www.ciscopress.com/articles/article.asp?p=2756480&seqNum=2 |access-date=2024-12-18 |website=www.ciscopress.com}}</ref>
* Static routing causes very little load on the [[CPU]] of the router, and produces no traffic to other routers.
* It does not require connectivity to work, providing high fault tolerance in case of network failures.
* Static routing leaves the network administrator with full control over the routing behavior of the network.
* Compared to dynamic routing protocols, static routes are much more widely available, for instance, many low-end consumer switches are capable of setting static routes.{{cn|date=December 2024}}
* Static Routing Is very easy to configure on small networks.
* As static routes are not read from the network, there are also fewer security considerations. Dynamic routing protocols may need to be secured such that an attacker cannot redirect traffic from the outside.<ref>{{Cite web |title=IP Routing Configuration Guide, Cisco IOS XE 17.16.x (Catalyst 9500 Switches) - Configuring OSPFv3 Authentication Support with IPsec |url=https://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst9500/software/release/17-16/configuration_guide/rtng/b_1716_rtng_9500_cg/configuring_ospfv3_authentication_support_with_ipsec.html |access-date=2024-12-18 |website=Cisco |language=en}}</ref>
 
== Disadvantages ==
Static routing can have some potential disadvantages:<ref>Tetz{{Cite Eweb (n|title=Cisco Networking Articles |url=https://www.d),dummies.com/category/articles/cisco-33583/ [|access-date=2013-11-05 |website=dummies |language=en |archive-url=https://web.archive.org/web/20131105090942/http://www.dummies.com/how-to/content/pros-and-cons-of-static-routing.html Pros and Cons of Static Routing] www.dummies.com, accessed 5 November |archive-date=2013-11-05}}</ref>
* '''Human error:''' As the routes have to be manually configured this may be a source of human error in the absence of automated configuration management.
 
* '''Administrative overhead:''' Similarly the routes have to be provided to the devices. This can be remedied by configuration management, but also using simpler means of using a [[Template processor|template engine]] to generate configuration using repetition or [[IP address management]] software.
* '''Human error:''' In many cases, static routes are manually configured. This increases the potential for input mistakes. Administrators can make mistakes and mistype in network information, or configure incorrect routing paths by mistake.
* '''Fault tolerance:''' While static routes not being removed during a network failure can be good in that routes continue to function, however, most implementations continue to use a static route as long as the interface the gateway is on is in an ''up'' state. When [[Failure of electronic components|network hardware fails]] it is not necessary ''down''; a [[Hang (computing)|hang]] may cause interfaces to keep running but not accept traffic. Routing protocols usually implement timeouts after which routes are removed or have integration with additional protocols such as [[Bidirectional Forwarding Detection]] to reduce the time the faulty route is present to sub-second.
* '''Fault tolerance:''' Static routing is not fault tolerant. This means that when there is a change in the network or a failure occurs between two statically defined devices, traffic will not be re-routed. As a result, the network is unusable until the failure is repaired or the static route is manually reconfigured by an administrator.
* '''Observability:''' Static routes themselves do not propagate, which means that in a network built using only static routes it is hard to get a big picture of all present routes unless [[Event monitoring|monitored]]. Dynamic routing protocols often transmit topology information or can be connected to debugging tools such as a [[Looking Glass server]].
* '''Administrative distance:''' Static routes typically take precedence over routes configured with a dynamic routing protocol. This means that static routes may prevent [[routing protocols]] from working as intended. A solution is to manually modify the [[administrative distance]].<ref>Cisco Systems (n.d), [http://www.cisco.com/en/US/docs/switches/datacenter/sw/5_x/nx-os/unicast/configuration/guide/l3_route.html Configuring Static Routing], accessed 5 November 2013</ref>
* '''Administrative overhead:''' Static routes must be configured on each [[router (computing)|router]] in the network(s). This configuration can take a long time if there are many routers. It also means that reconfiguration can be slow and inefficient. Dynamic routing on the other hand automatically propagates routing changes, reducing the need for manual reconfiguration.
 
== Example ==
Line 27 ⟶ 31:
 
=== Linux ===
Linux distributions generally provide a variety of network configuration software for users to use,<ref>{{Cite web |title=Chapter 5. Network setup |url=https://www.debian.org/doc/manuals/debian-reference/ch05.en.html |access-date=2024-12-18 |website=www.debian.org}}</ref> but also ship with a default such as [[Systemd#Ancillary components|systemd-networkd]] or ''ifupdown''.<ref>{{Cite web |title=8.2. Configuring the Network |url=https://www.debian.org/doc/manuals/debian-handbook/sect.network-config.en.html |access-date=2024-12-18 |website=www.debian.org}}</ref>
In most Linux distributions, a static route can be added using the [[iproute2]] command. The following is typed at a terminal:-<ref name=Linux>https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/s1-networkscripts-static-routes.html</ref>
The configuration software of choice is then used to configure the persistent configuration which is applied on boot.
It is also possible to configure Linux networking ad-hoc using the ''ip'' command from the [[iproute2]] package.
InThe mostfollowing Linuxcommand distributions,can abe staticused routeto canconfigure bethe addedroute using the''ip'':<ref [[iproute2]]name=Linux>{{Cite commandweb |title = 16.4. TheStatic followingRoutes isand typedthe atDefault aGateway terminal:-<refRed Hat Enterprise name=Linux> 5 |url=https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/s1-networkscripts-static-routes.html |access-date=2024-12-18 |website=docs.redhat.com}}</ref>
 
<sourcesyntaxhighlight lang="console">root@router:~# ip route add 10.10.20.0/24 via 192.168.100.1</sourcesyntaxhighlight>
 
=== Cisco ===
[[Cisco routers]] running the [[Cisco IOS]] operating system can be configured using the command line interface:<ref>{{Cite web |date=2013-02-02 |title=Cisco IOS IP Command Reference, Volume 2 of 4: Routing Protocols, Release 12.3 T - IP Routing Protocol Commands: ip policy route-map through is-type |url=http://www.cisco.com/en/US/docs/ios/12_3t/ip_route/command/reference/ip2_i2gt.html#wp1106404 |access-date=2024-12-18 |archive-url=https://web.archive.org/web/20130202041013/http://www.cisco.com/en/US/docs/ios/12_3t/ip_route/command/reference/ip2_i2gt.html#wp1106404 |archive-date=2 February 2013 }}</ref>
Enterprise-level [[Cisco Systems|Cisco routers]] are configurable using the Cisco IOS command line, rather than a web management interface.
 
==== Add a static route ====
 
The commands to add a static route are as follows:<ref name="ip route">[http://www.cisco.com/en/US/docs/ios/12_3t/ip_route/command/reference/ip2_i2gt.html#wp1106404 ip route]</ref>
 
'''Router>''' enable
'''Router#''' configure terminal
'''Router(config)#''' interface s0/0/0
'''Router(config)#''' ip route 10.10.20.0 255.255.255.0 192.168.100.1
 
Network configurations are not restricted to a single static route per destination:<ref name="ip route"/>
 
'''Router>''' enable
'''Router#''' configure terminal
'''Router(config)#''' ip route 197.164.73.0 255.255.255.0 197.164.72.2
'''Router(config)#''' ip route 197.164.74.0 255.255.255.0 197.164.72.2
 
==== Add static route by specifying exit interface ====
 
Static routes can also be added by specifying the exit interface rather than the "next hop" IP address of the router.
 
<syntaxhighlight lang="console">
<code>'''Router(config)#''' ip route 10.10.20.0 255.255.255.0 Serial 0/0/0 </code>
> enable
'''Router#''' configure terminal
'''Router(config)#''' ip route 10.10.20.0 255.255.255.0 192.168.100.1
</syntaxhighlight>
 
==== Configuring administrative distance ====
 
The administrative distance can be manually (re)configured so that the static route can be configured as a backup route, to be used only if the dynamic route is unavailable.<ref name=distance>Cisco{{Cite Systemsweb (2013),|title=Describe Administrative [httpDistance |url=https://www.cisco.com/c/en/USus/techsupport/tk365docs/technologies_tech_note09186a0080094195ip/border-gateway-protocol-bgp/15986-admin-distance.shtml What is Administrative Distance?], retrievedhtml |access-date=2014-06-12 June|website=Cisco 2014|language=en}}</ref>
 
<codesyntaxhighlight lang="console">'''Router(config)#''' ip route 10.10.20.0 255.255.255.0 exampleRoute 1 254</codesyntaxhighlight>
 
Setting the administrative distance to 254 will result in the route being used only as a backup.
Line 66 ⟶ 57:
== See also ==
{{div col|colwidth=20em}}
* [[Routing]]
* [[Dynamic routing]]
* [[Routing protocol]]
* [[Routing table]]
* [[routerRouter (computing)|Router]]
* [[Route (disambiguation)|Route]]
* [[Routing#Path selection|Metrics]]
{{div col end}}