<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic bash script to setup a route in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/bash-script-to-setup-a-route/m-p/4786024#M81308</link>
    <description>hi&lt;BR /&gt;&lt;BR /&gt;I need a bash script running with root rights to setup a route, for example: &lt;BR /&gt;&lt;BR /&gt;0.0.0.0 0.0.0.0 192.168.0.1&lt;BR /&gt;&lt;BR /&gt;It should run on linux as a startup application.&lt;BR /&gt;&lt;BR /&gt;THX</description>
    <pubDate>Tue, 10 May 2011 08:22:14 GMT</pubDate>
    <dc:creator>'chris'</dc:creator>
    <dc:date>2011-05-10T08:22:14Z</dc:date>
    <item>
      <title>bash script to setup a route</title>
      <link>https://community.hpe.com/t5/operating-system-linux/bash-script-to-setup-a-route/m-p/4786024#M81308</link>
      <description>hi&lt;BR /&gt;&lt;BR /&gt;I need a bash script running with root rights to setup a route, for example: &lt;BR /&gt;&lt;BR /&gt;0.0.0.0 0.0.0.0 192.168.0.1&lt;BR /&gt;&lt;BR /&gt;It should run on linux as a startup application.&lt;BR /&gt;&lt;BR /&gt;THX</description>
      <pubDate>Tue, 10 May 2011 08:22:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/bash-script-to-setup-a-route/m-p/4786024#M81308</guid>
      <dc:creator>'chris'</dc:creator>
      <dc:date>2011-05-10T08:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: bash script to setup a route</title>
      <link>https://community.hpe.com/t5/operating-system-linux/bash-script-to-setup-a-route/m-p/4786025#M81309</link>
      <description>Most Linux distributions include configuration files you can use to specify custom routes. You probably don't need a script. (If such a configuration file is available, other sysadmins will expect to find custom routes there, not in arbitrary custom scripts. Being purposefully obscure only imperils your hard-earned vacation time.)&lt;BR /&gt;&lt;BR /&gt;For example, on RedHat Enterprise Linux, if you need custom routes for e.g. network interface eth0, you can create a file named /etc/sysconfig/network-scripts/route-eth0 and write your route definition to it. &lt;BR /&gt;&lt;BR /&gt;Please see:&lt;BR /&gt;&lt;A href="http://www.cyberciti.biz/tips/configuring-static-routes-in-debian-or-red-hat-linux-systems.html" target="_blank"&gt;http://www.cyberciti.biz/tips/configuring-static-routes-in-debian-or-red-hat-linux-systems.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Furthermore, your example route has network 0/netmask 0, which means it's a default gateway route. All Linux distributions have a way to specify a default gateway without any need of custom scripting.&lt;BR /&gt;&lt;BR /&gt;Even if you for some reason need a script, the script would just be an one-line "route" or "ip" command:&lt;BR /&gt;&lt;BR /&gt;route add default gw 192.168.0.1&lt;BR /&gt;or&lt;BR /&gt;ip route add default via 192.168.0.1&lt;BR /&gt;&lt;BR /&gt;The standard place for adding custom one-line commands to system startup would be the "rc.local" file, usually located in either /etc/rc.local or /etc/init.d/rc.local. It is automatically run as root at system startup.&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Tue, 10 May 2011 09:21:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/bash-script-to-setup-a-route/m-p/4786025#M81309</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2011-05-10T09:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: bash script to setup a route</title>
      <link>https://community.hpe.com/t5/operating-system-linux/bash-script-to-setup-a-route/m-p/4786026#M81310</link>
      <description>Pls let explain our problem.&lt;BR /&gt;In the branch office we have 2 breakouts: 1 standard over MPLS and other one, just temporaily for some tests over DSL. &lt;BR /&gt;The default (standard) gateway  for our branch clients is MPLS router and the standard internet breakout is normally over the same MPLS router.&lt;BR /&gt;We have ordered now DSL, just for some tests.&lt;BR /&gt;BTW It's quite difficult to change routings at MPLS or DSL router by the providers.&lt;BR /&gt;We try to change routings on the linux clients.&lt;BR /&gt;&lt;BR /&gt;I've add these lines in: /etc/sudoers:&lt;BR /&gt;&lt;BR /&gt;sta ALL=(root)NOPASSWD:/home/user/route.sh&lt;BR /&gt;sta ALL=(root)NOPASSWD:/sbin/route&lt;BR /&gt;&lt;BR /&gt;and I've created this script, not tested yet:&lt;BR /&gt;---------------------------------------------------------&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;&lt;BR /&gt;# del existing default gw (MPLS router)&lt;BR /&gt;sudo route del default&lt;BR /&gt;&lt;BR /&gt;# set DSL router as default gw&lt;BR /&gt;sudo route add default gw 192.168.0.1&lt;BR /&gt;&lt;BR /&gt;# set route for the internal MPLS network&lt;BR /&gt;sudo route add 10.10.0.0 netmask 255.255.0.0 gw 10.10.50.1 dev eth0&lt;BR /&gt;------------------------------------------------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;Perhaps I should create another script to change everything back.&lt;BR /&gt;Both scripts should be run by a normal non-root user.&lt;BR /&gt;</description>
      <pubDate>Tue, 10 May 2011 15:43:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/bash-script-to-setup-a-route/m-p/4786026#M81310</guid>
      <dc:creator>'chris'</dc:creator>
      <dc:date>2011-05-10T15:43:35Z</dc:date>
    </item>
  </channel>
</rss>

