{"id":1319,"date":"2011-08-18T23:46:21","date_gmt":"2011-08-18T15:46:21","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=1319"},"modified":"2023-06-25T09:20:41","modified_gmt":"2023-06-25T09:20:41","slug":"how-to-add-persistent-static-routes-in-centos-5-6","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-add-persistent-static-routes-in-centos-5-6\/","title":{"rendered":"How to Add Persistent Static Routes in CentOS 5.6"},"content":{"rendered":"<p>In web servers, it&#8217;s crucial to understand how to configure various aspects of your system to ensure optimal performance and reliability. One such configuration is the persistent static route in CentOS 5.6 server.<\/p>\n<p>This tutorial will guide you through the process of setting up a persistent static route in CentOS 5.6. This configuration may differ with other versions of CentOS, but the basics remain the same. A persistent static route will permanently store the setting and will not be deleted even after the system is rebooted.<\/p>\n<p>For more in-depth information about web servers, you can visit our guide on the <a href=\"https:\/\/webhostinggeeks.com\/best\/web-server\/\">best web servers<\/a>. If you&#8217;re interested in learning more about specific servers like <a href=\"https:\/\/webhostinggeeks.com\/blog\/apache-http-server-explained\/\">Apache<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/nginx-server-explained\/\">Nginx<\/a>, or <a href=\"https:\/\/webhostinggeeks.com\/blog\/litespeed-web-server-explained\/\">LiteSpeed<\/a>, we have detailed articles on those as well.<\/p>\n<h2>Step 1: Navigate to the Network Scripts Directory<\/h2>\n<p>The first step in configuring a persistent static route is to navigate to the network scripts directory. This can be done by using the following command:<\/p>\n<pre>cd \/etc\/sysconfig\/network-scripts\/<\/pre>\n<h2>Step 2: Modify the Default Route<\/h2>\n<p>Next, you need to modify the original default route to meet your requirements. This can be done by using the &#8216;vi&#8217; command to open the &#8216;route-eth0&#8217; file:<\/p>\n<pre>vi route-eth0<\/pre>\n<p>Inside this file, you will see something like this:<\/p>\n<pre>\r\n192.0.2.0\/24 dev eth0 scope host\r\ndefault via 192.0.2.1\r\n<\/pre>\n<p>You need to change it to the following:<\/p>\n<pre>\r\n192.0.2.0\/24 dev eth0 scope host\r\ndefault via 192.0.2.1\r\n192.168.2.0\/24 via 192.168.13.1 dev eth0\r\n<\/pre>\n<h2>Step 3: Restart the Network<\/h2>\n<p>After modifying the default route, you need to restart the network to apply the new routing table. This can be done by using the following command:<\/p>\n<pre>service network restart<\/pre>\n<p>To verify that the new routing table has been applied, you can use the &#8216;netstat -rn&#8217; command:<\/p>\n<pre>netstat -rn<\/pre>\n<p>This will display the Kernel IP routing table, where you should see your newly added static route.<\/p>\n<pre>\r\n[root@server network-scripts]# netstat -rn\r\nKernel IP routing table\r\nDestination     Gateway         Genmask         Flags   MSS Window  irtt Iface\r\n192.168.2.0     192.168.13.1    255.255.255.0   UG        0 0          0 eth0\r\n192.0.2.0       0.0.0.0         255.255.255.0   U         0 0          0 eth0\r\n169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0\r\n0.0.0.0         0.0.0.0         0.0.0.0         U         0 0          0 eth0\r\n<\/pre>\n<h2>Commands Mentioned<\/h2>\n<ul>\n<li><span class=\"fw-bold\">cd \/etc\/sysconfig\/network-scripts\/<\/span> \u2013 This command is used to navigate to the network scripts directory.<\/li>\n<li><span class=\"fw-bold\">vi route-eth0<\/span> \u2013 This command is used to open the &#8216;route-eth0&#8217; file for editing.<\/li>\n<li><span class=\"fw-bold\">service network restart<\/span> \u2013 This command is used to restart the network and apply the new routing table.<\/li>\n<li><span class=\"fw-bold\">netstat -rn<\/span> \u2013 This command is used to display theKernel IP routing table, which allows you to verify that your new static route has been added.<br \/>\n<h2>Conclusion<\/h2>\n<p>Configuring a persistent static route in CentOS 5.6 is a straightforward process that involves navigating to the network scripts directory, modifying the default route to meet your requirements, and restarting the network to apply the new routing table. This guide has provided step-by-step instructions to help you perform this task with ease.<\/p>\n<p>Remember, understanding your server&#8217;s configuration is key to optimizing its performance and reliability. Whether you&#8217;re working with a <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-dedicated-server-hosting\/\">dedicated server<\/a>, a <a href=\"https:\/\/webhosting.com\/blog\/what-is-vps-hosting\/\">VPS server<\/a>, <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-cloud-hosting\/\">cloud hosting<\/a>, or <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-shared-hosting\/\">shared hosting<\/a>, having a solid understanding of your server&#8217;s configuration can make a significant difference in its performance.<\/p>\n<p>By following this guide, you&#8217;ve taken a step towards better understanding and controlling your server&#8217;s network routing. Keep exploring and learning, and you&#8217;ll be well on your way to becoming a server administration expert.<\/p>\n<h2>FAQ Section<\/h2>\n<ol itemscope itemtype=\"https:\/\/schema.org\/FAQPage\">\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<h3 class=\"fw-bold\" itemprop=\"name\">What is a persistent static route?<\/h3>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">A persistent static route is a permanent routing path stored in a server&#8217;s configuration. It remains intact even after the system is rebooted, ensuring consistent network communication.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<h3 class=\"fw-bold\" itemprop=\"name\">Why do we need to modify the default route?<\/h3>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Modifying the default route is necessary when you need to direct network traffic in a specific way that differs from the existing default route. This can be for reasons such as optimizing network performance or managing multiple networks.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<h3 class=\"fw-bold\" itemprop=\"name\">What does the &#8216;service network restart&#8217; command do?<\/h3>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The &#8216;service network restart&#8217; command is used to restart the network service on a server. This is necessary when you have made changes to the network configuration, such as adding a new static route, and you need these changes to take effect.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<h3 class=\"fw-bold\" itemprop=\"name\">How can I verify that my new static route has been added?<\/h3>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">You can verify that your new static route has been added by using the &#8216;netstat -rn&#8217; command. This command displays the Kernel IP routing table, where you should see your newly added static route.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<h3 class=\"fw-bold\" itemprop=\"name\">What is the role of the &#8216;vi&#8217; command in this process?<\/h3>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The &#8216;vi&#8217; command is a text editor command in Linux. In this process, it is used to open the &#8216;route-eth0&#8217; file for editing, allowing you to modify the default route as needed.<\/span>\n            <\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>In web servers, it&#8217;s crucial to understand how to configure various aspects of your system to ensure optimal performance and reliability. One such configuration is the persistent static route in&#8230;<\/p>\n","protected":false},"author":6,"featured_media":349,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1059],"tags":[1247,2089,1536,1802],"class_list":["post-1319","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-static-route","tag-centos-5-6","tag-configuration","tag-linux","tag-static-routes"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/1319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=1319"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/1319\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/349"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=1319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=1319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=1319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}