{"id":2758,"date":"2020-02-21T07:44:00","date_gmt":"2020-02-21T02:14:00","guid":{"rendered":"https:\/\/www.24x7serversupport.com\/blog\/?p=2758"},"modified":"2020-02-22T21:40:00","modified_gmt":"2020-02-22T16:10:00","slug":"how-to-add-and-delete-static-route-in-linux-using-ip-command","status":"publish","type":"post","link":"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/","title":{"rendered":"How to Add and Delete Static Route in Linux using IP Command"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Viewing the existing routing table<\/h4>\n\n\n\n<p>Before we embark on adding or deleting routes, it\u2019s prudent to check the existing default routes on a system. To do so, simply launch your terminal and issue the command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ ip route show\nOr\n$ ip route list\n\n Similar statistics can be displayed using route command,\n$ route -n\n\nOr simply,\n$ route \n<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Adding a static route using IP command<\/h4>\n\n\n\n<p>Suppose you want to take a backup of a Linux machine and push the backup file to another backup server in the subnet&nbsp;<strong>10.0.2.0\/24<\/strong>. However, for one reason or the other, you cannot reach the backup server&nbsp; via the default gateway. In this case, you will have to create a new route for backup server subnet via another IP, say&nbsp;<strong>192.168.43.223<\/strong>&nbsp;via the interface&nbsp;<strong>enp0s3<\/strong>.<\/p>\n\n\n\n<p>The command for this will be<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo ip route add 10.0.2.0\/24 via 192.168.43.223 dev enp0s3<\/pre>\n\n\n\n<p>Where:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>10.0.2.0 &nbsp;&nbsp;&nbsp;&nbsp; -&gt; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; is the network you want to connect to<\/li><li>\/24&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; is the subnet mask<\/li><li>192.168.43.223 -&gt; &nbsp;&nbsp; is the IP through which we will reach the server<\/li><li>enp0s3 &nbsp;&nbsp; &nbsp;&nbsp; -&gt; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; is the network interface<\/li><\/ul>\n\n\n\n<p>You can confirm whether new static route add been in route table using \u201c<strong>ip route show<\/strong>\u201d command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo ip route show<\/pre>\n\n\n\n<p>To add the specific IP of the backup server, say 10.0.2.15 run the command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo ip route add 10.0.2.15 via 192.168.43.223 dev enp0s3<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.linuxtechi.com\/wp-content\/uploads\/2020\/02\/ip-route-add-single-ip-linux.png?w=640&#038;ssl=1\" alt=\"ip-route-add-single-ip-linux\" class=\"wp-image-9770\" data-recalc-dims=\"1\"\/><\/figure>\n\n\n\n<p>Once again, you can check the routing changes to see if the changes exist using the ip route show command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ ip route show<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Viewing the existing routing table Before we embark on adding or deleting routes, it\u2019s prudent to check the existing default routes on a system. To do so, simply launch your terminal and issue the command: $ ip route show Or $ ip route list Similar statistics can be displayed using route command, $ route -n [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"class_list":["post-2758","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Add and Delete Static Route in Linux using IP Command | 24x7serversupport Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Add and Delete Static Route in Linux using IP Command | 24x7serversupport Blog\" \/>\n<meta property=\"og:description\" content=\"Viewing the existing routing table Before we embark on adding or deleting routes, it\u2019s prudent to check the existing default routes on a system. To do so, simply launch your terminal and issue the command: $ ip route show Or $ ip route list Similar statistics can be displayed using route command, $ route -n [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/\" \/>\n<meta property=\"og:site_name\" content=\"24x7serversupport Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-02-21T02:14:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-02-22T16:10:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.linuxtechi.com\/wp-content\/uploads\/2020\/02\/ip-route-add-single-ip-linux.png\" \/>\n<meta name=\"author\" content=\"24x7support\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:site\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"24x7support\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/\",\"name\":\"How to Add and Delete Static Route in Linux using IP Command | 24x7serversupport Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.linuxtechi.com\/wp-content\/uploads\/2020\/02\/ip-route-add-single-ip-linux.png\",\"datePublished\":\"2020-02-21T02:14:00+00:00\",\"dateModified\":\"2020-02-22T16:10:00+00:00\",\"author\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/#primaryimage\",\"url\":\"https:\/\/www.linuxtechi.com\/wp-content\/uploads\/2020\/02\/ip-route-add-single-ip-linux.png\",\"contentUrl\":\"https:\/\/www.linuxtechi.com\/wp-content\/uploads\/2020\/02\/ip-route-add-single-ip-linux.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.24x7serversupport.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Add and Delete Static Route in Linux using IP Command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/\",\"name\":\"24x7serversupport Blog\",\"description\":\"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\",\"name\":\"24x7support\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Add and Delete Static Route in Linux using IP Command | 24x7serversupport Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/","og_locale":"en_US","og_type":"article","og_title":"How to Add and Delete Static Route in Linux using IP Command | 24x7serversupport Blog","og_description":"Viewing the existing routing table Before we embark on adding or deleting routes, it\u2019s prudent to check the existing default routes on a system. To do so, simply launch your terminal and issue the command: $ ip route show Or $ ip route list Similar statistics can be displayed using route command, $ route -n [&hellip;]","og_url":"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/","og_site_name":"24x7serversupport Blog","article_published_time":"2020-02-21T02:14:00+00:00","article_modified_time":"2020-02-22T16:10:00+00:00","og_image":[{"url":"https:\/\/www.linuxtechi.com\/wp-content\/uploads\/2020\/02\/ip-route-add-single-ip-linux.png"}],"author":"24x7support","twitter_card":"summary_large_image","twitter_creator":"@24x7serversuppo","twitter_site":"@24x7serversuppo","twitter_misc":{"Written by":"24x7support","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/","url":"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/","name":"How to Add and Delete Static Route in Linux using IP Command | 24x7serversupport Blog","isPartOf":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/#primaryimage"},"image":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/#primaryimage"},"thumbnailUrl":"https:\/\/www.linuxtechi.com\/wp-content\/uploads\/2020\/02\/ip-route-add-single-ip-linux.png","datePublished":"2020-02-21T02:14:00+00:00","dateModified":"2020-02-22T16:10:00+00:00","author":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401"},"breadcrumb":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/#primaryimage","url":"https:\/\/www.linuxtechi.com\/wp-content\/uploads\/2020\/02\/ip-route-add-single-ip-linux.png","contentUrl":"https:\/\/www.linuxtechi.com\/wp-content\/uploads\/2020\/02\/ip-route-add-single-ip-linux.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-add-and-delete-static-route-in-linux-using-ip-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.24x7serversupport.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Add and Delete Static Route in Linux using IP Command"}]},{"@type":"WebSite","@id":"https:\/\/www.24x7serversupport.com\/blog\/#website","url":"https:\/\/www.24x7serversupport.com\/blog\/","name":"24x7serversupport Blog","description":"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401","name":"24x7support","url":"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/2758","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/comments?post=2758"}],"version-history":[{"count":1,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/2758\/revisions"}],"predecessor-version":[{"id":2759,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/2758\/revisions\/2759"}],"wp:attachment":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media?parent=2758"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/categories?post=2758"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/tags?post=2758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}