Routing Script+DHCP and interface routing support

The "routing configurator" script now supports DHCP and interface routing (in addition to static IP routing). The script provides support for multiple gateways on multiple interfaces, and allows designation of the Internet 'route of last resort' for a particular gateway of one's choosing.The script can be downloaded via HTTP, for now, from:

http://www.securityappraisers.net/downloads/routes.tar  

The script can be extracted to /sbin/init.d/routes.local (this is a 'hook' wisely provided by Astaro; a script in this location gets called whenever a change is made to the "Routes" or "Interfaces" pages in the webadmin). This script has been tested with version 4. This script serves as a good example of adapting Astaro to your needs. If you have ideosyncratic routing requirements, this script can serve as a good point of departure.

The MD5 for the script is:

f8c6d9dabde6ba823c6952b55da40351 

[Check posts below to see if this script has been updated; newer MD5 signatures will be listed in such posts]

Specify individual gateways for multiple interfaces; then add an "Any" route on the "Routes" page of the webadmin, specifying a target gateway of either an interface or a host. In the case of an interface target, the script will obtain the gateway from the interface's static gateway entry, or, in the case of DHCP, from the gateway brokered by a DHCP server.

This script will:

  • flush all prior routes (except loopback network 127.0.0.0)
  • add routes for the network defined by each interface's address and mask (also specifying a gateway if one is specified on the interface)
    [the interface that will support the route of last resort will not be specified as a subnetwork route, since the route of last resort should cover this...]
  • add specific routes specified on the Routes webadmin page (based on networks that are not labeled "Any")
  • add routes of last resort (0.0.0.0) for targets labeled "Any" [there should only be one "Any"/"route of last resort"; dead gateway is not supported in this script implementation...)
[/list]
The script generates an HTML formatted log in Astaro's web publishing directory. This log can be accessed from the webadmin by using a url of: 

https://your_webadmin_url/routes.htm

This software is neither expressly endorsed nor supported by Astaro.

Although reasonable efforts of software quality assurance have been made, this free software implies no obligations of support or liability by SecurityAppraisers.

Trivial sanity checking of data is performed by this script; but routing and interface misconfigurations are NOT handled (e.g., two interfaces having the same address, or overlapping networks, etc.). 

For extra details read the comments in the script.

NoteFrom a troubleshooting, reliability, and security perspective, it is almost always preferable to use static IP addressing on your vital Internet gateways, as opposed to DHCP.  Having said that, we understand the constraints that many people may be working under that requires them to employ DHCP on their gateway addressing...
              
Parents
  • Steve,

    Will this routing script work in the following configuration?  (Please ignore all the dots, they are place holders.

                                  
    ..............................Internet Side
    DHCP....................................................Static
    ...|................................................................|
    ...|................................................................|
    ...|................................................................|
    ...|................................................................|
    ...|................................................................|
    ..+++++++++...astaro..+++++++++++++
    ...............................|
    ...............................|
    ...............................|   
    Internal Side  (web and smtp server)


    Where a port forwarded web server and smtp server exist on the internal size?  I.E., will it properly send the data back through the correct gateway depending upon where the request originated from the internet?

    Will it also provide _basic_ failover for outgoing requests from the internal network if one of the Internet connections fails?

    Thanks Very Much,

    .dn
       
Reply
  • Steve,

    Will this routing script work in the following configuration?  (Please ignore all the dots, they are place holders.

                                  
    ..............................Internet Side
    DHCP....................................................Static
    ...|................................................................|
    ...|................................................................|
    ...|................................................................|
    ...|................................................................|
    ...|................................................................|
    ..+++++++++...astaro..+++++++++++++
    ...............................|
    ...............................|
    ...............................|   
    Internal Side  (web and smtp server)


    Where a port forwarded web server and smtp server exist on the internal size?  I.E., will it properly send the data back through the correct gateway depending upon where the request originated from the internet?

    Will it also provide _basic_ failover for outgoing requests from the internal network if one of the Internet connections fails?

    Thanks Very Much,

    .dn
       
Children
  • It will not do fallover (we did another script for hire called the "Dead Gateway Detector" [not published] that does this; Astaro is working on a general purpose and extensible one too for inclusion in one of the next releases). As suggested above, you could use this+hack backroute (made by a fellow in Switzerland) to take it's marching orders from /etc/wfe/conf/routesdata (as opposed to the hardcoded Bash script variables that backroute uses).

    You can designate the route of last resort through an "Any" route definition (e.g., you could choose to have your Internet go out one interface, and then by redefining that same Any route, it will then go out another interface).

    [The Dead Gateway Detector uses this, by periodically testing gateways with ICMP and then rewriting the Any route in /etc/wfe/conf/routesdata should it see that a gateway died; upon alteration of routesdata, this routing script gets automatically reinvoked by Astaro (by having been placed in a special directory location that Astaro checks) and -presto! new gateway to the 'net; so hack backroute and you could have the same thing -and you will get better at writing a Bash script! cf., Advanced Bash Scripting Guide]

    Ideosyncratic destination routes can be added, and it will pass it out the appropriate interface you designated. As for incoming packets (DNAT), it should work, though I will be honest and say it hasn't been tested for that case yet (you can see why Astaro doesn't always make this stuff available right away; but I found we needed that functionality desperately for certain applications). Try it; it generates a quite thorough routing configuration log for the webadmin, so you can send it to me offline if you should have any problems, and I should have all the info I need to figure things out. It's really simple to use (IF you know what routing you want to do)...