{"id":3730,"date":"2023-11-21T12:13:21","date_gmt":"2023-11-21T04:13:21","guid":{"rendered":"https:\/\/www.servergigabit.com\/guide\/?post_type=kb&#038;p=3730"},"modified":"2026-03-16T12:19:37","modified_gmt":"2026-03-16T04:19:37","slug":"configuring-static-routes-networking","status":"publish","type":"kb","link":"https:\/\/www.servergigabit.com\/guide\/kb\/configuring-static-routes-networking","title":{"rendered":"5 Essential Steps to Configuring Static Routes for Network"},"content":{"rendered":"<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-3731\" src=\"https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/e-300x169.jpeg\" alt=\"Configuring Static Routes\" width=\"715\" height=\"403\" srcset=\"https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/e-300x169.jpeg 300w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/e-1024x576.jpeg 1024w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/e-768x432.jpeg 768w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/e-1536x864.jpeg 1536w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/e-2048x1152.jpeg 2048w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/e-370x208.jpeg 370w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/e-1230x692.jpeg 1230w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/e-800x450.jpeg 800w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/e-390x219.jpeg 390w\" sizes=\"(max-width: 715px) 100vw, 715px\" \/><\/p>\n<p data-sourcepos=\"5:1-5:226\">Configuring static routes that inform routers about the best path to reach specific destinations. They are useful when the default routing table does not have the necessary information to route traffic correctly.<\/p>\n<p data-sourcepos=\"9:1-9:219\">In the provided scenario, direct communication between servers on the same subnet is not possible due to layer-2 traffic restrictions. To enable communication between these servers, static routes need to be established.<\/p>\n<h2 data-sourcepos=\"11:1-11:26\"><strong>Creating Static Routes<\/strong><\/h2>\n<p data-sourcepos=\"13:1-13:125\">The process of creating static routes varies depending on the operating system. Here&#8217;s a breakdown for each operating system:<\/p>\n<h5 data-sourcepos=\"9:1-9:10\"><a href=\"https:\/\/www.centos.org\/\" rel=\"nofollow noopener\" target=\"_blank\"><strong>CentOS<\/strong><\/a><\/h5>\n<ol data-sourcepos=\"11:1-13:0\">\n<li data-sourcepos=\"11:1-11:63\">Open the route-eth0 file in \/etc\/sysconfig\/network-scripts\/.<\/li>\n<li data-sourcepos=\"12:1-13:0\">Add the following line to the file:<\/li>\n<\/ol>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">192.51.100.42\/32 via 192.51.100.1 dev eth0\r\n<\/code><\/pre>\n<\/div>\n<ol start=\"3\" data-sourcepos=\"18:1-20:0\">\n<li data-sourcepos=\"18:1-18:17\">Save the file.<\/li>\n<li data-sourcepos=\"19:1-20:0\">Repeat steps 1-3 on the other server, replacing 192.51.100.42 with the IP address of the other server.<\/li>\n<\/ol>\n<h5 data-sourcepos=\"21:1-21:31\"><strong><a href=\"https:\/\/www.debian.org\/\" target=\"_blank\" rel=\"noopener\">Debian<\/a>\/<a href=\"https:\/\/ubuntu.com\/\" target=\"_blank\" rel=\"noopener\">Ubuntu<\/a> (until 17.04)<\/strong><\/h5>\n<ol data-sourcepos=\"23:1-25:0\">\n<li data-sourcepos=\"23:1-23:41\">Open the \/etc\/network\/interfaces file.<\/li>\n<li data-sourcepos=\"24:1-25:0\">Add the following lines to the file:<\/li>\n<\/ol>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\"><span class=\"citation-0 citation-end-0\">up ip route add 192.51.100.42\/32 via 192.51.100.1 dev eth0\r\ndown ip route del 192.51.100.42\/32 via 192.51.100.1 dev eth0<\/span>\r\n<\/code><\/pre>\n<\/div>\n<ol start=\"3\" data-sourcepos=\"31:1-33:0\">\n<li data-sourcepos=\"31:1-31:17\">Save the file.<\/li>\n<li data-sourcepos=\"32:1-33:0\">Repeat steps 1-3 on the other server, replacing 192.51.100.42 with the IP address of the other server.<\/li>\n<\/ol>\n<h5 data-sourcepos=\"34:1-34:28\"><strong>Ubuntu (17.10 and above)<\/strong><\/h5>\n<ol data-sourcepos=\"36:1-38:0\">\n<li data-sourcepos=\"36:1-36:45\">Open the \/etc\/netplan\/01-netcfg.yaml file.<\/li>\n<li data-sourcepos=\"37:1-38:0\">Add the following lines to the file:<\/li>\n<\/ol>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">eth0:\r\n  routes:\r\n    - to: 192.51.100.0\/25\r\n      via: 192.51.100.1\r\n    - to: 192.51.100.128\/25\r\n      via: 192.51.100.1\r\n<\/code><\/pre>\n<\/div>\n<ol start=\"3\" data-sourcepos=\"48:1-50:0\">\n<li data-sourcepos=\"48:1-48:17\">Save the file.<\/li>\n<li data-sourcepos=\"49:1-50:0\">Run the following command:<\/li>\n<\/ol>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">sudo netplan apply\r\n<\/code><\/pre>\n<\/div>\n<h5 data-sourcepos=\"55:1-55:12\"><a href=\"https:\/\/www.opensuse.org\/\" rel=\"nofollow noopener\" target=\"_blank\"><strong>openSUSE<\/strong><\/a><\/h5>\n<ol data-sourcepos=\"57:1-59:0\">\n<li data-sourcepos=\"57:1-57:47\">Open the \/etc\/sysconfig\/network\/routes file.<\/li>\n<li data-sourcepos=\"58:1-59:0\">Add the following line to the file:<\/li>\n<\/ol>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">192.51.100.42\/32 192.51.100.1 - eth0\r\n<\/code><\/pre>\n<\/div>\n<ol start=\"3\" data-sourcepos=\"64:1-66:0\">\n<li data-sourcepos=\"64:1-64:17\">Save the file.<\/li>\n<li data-sourcepos=\"65:1-66:0\">Repeat steps 1-3 on the other server, replacing 192.51.100.42 with the IP address of the other server.<\/li>\n<\/ol>\n<h5 data-sourcepos=\"67:1-67:18\"><a href=\"https:\/\/www.microsoft.com\/en-us\/windows-server\" target=\"_blank\" rel=\"noopener\"><strong>Windows Server<\/strong><\/a><\/h5>\n<ol data-sourcepos=\"69:1-71:0\">\n<li data-sourcepos=\"69:1-69:54\">Open Command Prompt with administrative privileges.<br \/>\n<img decoding=\"async\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/01\/Lkwp0drL3pv5Qu5I.png\" alt=\"command prompt admin\" \/><\/li>\n<li data-sourcepos=\"70:1-71:0\">Enter the following command:<\/li>\n<\/ol>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">route -p add 192.51.100.42 mask 255.255.255.255 192.51.100.1\r\n<\/code><\/pre>\n<\/div>\n<ol start=\"3\" data-sourcepos=\"76:1-77:0\">\n<li data-sourcepos=\"76:1-77:0\">Repeat step 2 on the other server, replacing 192.51.100.42 with the IP address of the other server.<\/li>\n<\/ol>\n<h5 data-sourcepos=\"78:1-78:20\"><strong>Additional Notes<\/strong><\/h5>\n<ul data-sourcepos=\"80:1-82:0\">\n<li data-sourcepos=\"80:1-80:89\">The -p option in the Windows Server commands makes the route persistent across reboots.<\/li>\n<li data-sourcepos=\"81:1-82:0\">If you often reboot your Windows Server, it is advisable to create a .bat script to perform the step of deleting the default route automatically.<\/li>\n<\/ul>\n<h2 data-sourcepos=\"83:1-83:14\"><strong>Conclusion (Configuring Static Routes)<\/strong><\/h2>\n<p data-sourcepos=\"85:1-85:164\">Static routes are a useful tool for managing network traffic. They can be used to improve network performance, increase security, and troubleshoot network problems.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Configuring static routes that inform routers about the best path to reach specific destinations. They are useful when the default routing table does not have the necessary information to route traffic correctly. In the provided scenario, direct communication between servers on the same subnet is not possible due to layer-2 traffic restrictions. To enable communication between these servers, static routes&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"kbtopic":[1099],"kbtag":[1187],"class_list":["post-3730","kb","type-kb","status-publish","hentry","kbtopic-tutorials","kbtag-configuring-static-routes"],"_links":{"self":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/comments?post=3730"}],"version-history":[{"count":5,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3730\/revisions"}],"predecessor-version":[{"id":6292,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3730\/revisions\/6292"}],"wp:attachment":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/media?parent=3730"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=3730"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtag?post=3730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}