├── .gitignore ├── Makefile ├── README ├── debian ├── changelog ├── compat ├── control ├── copyright ├── postinst ├── postrm ├── prerm ├── rules └── source │ └── format ├── netgwm ├── netgwm.default ├── netgwm.init.d ├── netgwm.py └── samples ├── netgwm.yml ├── post-replace.d ├── conntrack.sh └── script.sh └── rt_tables.sample /.gitignore: -------------------------------------------------------------------------------- 1 | debian/files 2 | debian/netgwm.debhelper.log 3 | debian/netgwm.postinst.debhelper 4 | debian/netgwm.prerm.debhelper 5 | debian/netgwm.substvars 6 | debian/netgwm/ 7 | stamp 8 | 9 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: stamp 2 | 3 | stamp: 4 | touch stamp 5 | 6 | install: 7 | install -d $(DESTDIR)/usr/lib/netgwm/ 8 | install -d $(DESTDIR)/var/lib/netgwm/ 9 | install -d $(DESTDIR)/etc/netgwm/ 10 | install -d $(DESTDIR)/etc/init.d/ 11 | install -d $(DESTDIR)/etc/default/ 12 | install -d $(DESTDIR)/usr/sbin/ 13 | cp -r $(CURDIR)/samples/* $(DESTDIR)/etc/netgwm/ 14 | install $(CURDIR)/netgwm.py $(DESTDIR)/usr/lib/netgwm/netgwm.py 15 | install $(CURDIR)/netgwm.init.d $(DESTDIR)/etc/init.d/netgwm 16 | install $(CURDIR)/netgwm.default $(DESTDIR)/etc/default/netgwm 17 | install $(CURDIR)/netgwm $(DESTDIR)/usr/sbin/netgwm 18 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | NetGWM stands for Network Gateway Manager 2 | (http://flant.ru/projects/netgwm) 3 | 4 | NetGWM is a tool on Python used for automatically switching 5 | network gateway when your current ISP goes offline. 6 | 7 | How to deploy NetGWM? 8 | 0) Install prerequisites: 9 | - iproute2 10 | - conntrack (http://conntrack-tools.netfilter.org/) 11 | - python-yaml (http://pyyaml.org/) 12 | 1) Execute "make install". It will create /usr/lib/netgwm 13 | with netgwm.py and /etc/netgwm with configs and samples. 14 | 2) Using simple YAML configuration file (samples/netgwm.yml), 15 | you should define your gateways (by IPs or devices) and 16 | their priorities. In /etc/default/netgwm, you can change 17 | the period of checking gateways (by default, every 60 sec). 18 | 3) Add new routing table named "netgwm_check" to your iproute 19 | configuration file (/etc/iproute2/rt_tables; there is 20 | an example at samples/rt_tables.sample). It's done 21 | automatically in the Debian package. 22 | 4) Use /etc/init.d/netgwm to launch NetGWM. 23 | 24 | That's all! NetGWM will ping given addresses through your 25 | current gateway to check your Internet connection. If all 26 | of these addresses are down, NetGWM will switch your current 27 | gateway to a working one (with a highest priority). 28 | 29 | Other features: 30 | * A gateway is considered as working only after N seconds 31 | of successfull checks. This setting ("min_uptime") can be 32 | configured in netgwm.yml. 33 | * When a gateway with a higher priority goes back online 34 | NetGWM will automatically switch to it from the current 35 | one. 36 | * Every time NetGWM switches a network gateway, it will 37 | execute all the scripts placed in 38 | /etc/netgwm/post-replace.d (for more details, please have 39 | a look at samples/post-replace.d/script.sh). 40 | * NetGWM can maintain the full list of gateways statuses 41 | continually for your special needs (e.g. to be used in 42 | other software). This data is stored in 43 | /var/run/netgwm/gwstore.yml. This setting 44 | ("check_all_gateways") can be enabled in netgwm.yml. 45 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | netgwm (0.3+sci1) unstable; urgency=low 2 | 3 | * More automated install 4 | * Gateway switch logging 5 | * Fix crash when DNS resolving fails 6 | * Add init.d script 7 | * Add postchange hook to reset all UDP streams 8 | 9 | -- Vladimir Ipatov Sat, 6 Jun 2013 01:35:30 +0400 10 | 11 | netgwm (0.2-changeme4) changeme; urgency=low 12 | 13 | * Fixed readme and doc 14 | 15 | -- Nikolay Bogdanov Fri, 07 Jun 2013 12:46:06 +0400 16 | 17 | netgwm (0.2-changeme3) changeme; urgency=low 18 | 19 | * Fix in directory struct 20 | 21 | -- Nikolay Bogdanov Sat, 14 Jul 2012 00:23:30 +0400 22 | 23 | netgwm (0.2-changeme2) changeme; urgency=low 24 | 25 | * Fix 26 | 27 | -- Nikolay Bogdanov Sat, 14 Jul 2012 00:00:27 +0400 28 | 29 | netgwm (0.2-changeme1) changeme; urgency=low 30 | 31 | * Fix 32 | 33 | -- Nikolay Bogdanov Fri, 13 Jul 2012 18:40:14 +0400 34 | 35 | netgwm (0.1-changeme2) changeme; urgency=low 36 | 37 | * fixes 38 | 39 | -- Nikolay Bogdanov Thu, 12 Jul 2012 21:38:03 +0400 40 | 41 | netgwm (0.1-changeme1) changeme; urgency=low 42 | 43 | * Initial release 44 | 45 | -- Nikolay Bogdanov Tue, 10 Jul 2012 16:55:12 +0400 46 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: netgwm 2 | Section: admin 3 | Priority: extra 4 | Maintainer: Nikolay Bogdanov 5 | Build-Depends: debhelper (>= 5) 6 | Standards-Version: 3.8.4 7 | Homepage: https://flant.ru 8 | 9 | Package: netgwm 10 | Architecture: all 11 | Depends: ${misc:Depends}, python-yaml, python-minimal, conntrack 12 | Description: change uplink 13 | monitor uplink and change gateway 14 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This work was packaged for Debian by: 2 | 3 | Nikolay Bogdanov on Tue, 10 Jul 2012 16:55:12 +0400 4 | 5 | It was downloaded from: 6 | 7 | https://github.com/flant/netgwm 8 | 9 | Upstream Author(s): 10 | 11 | Andrey Polovov 12 | 13 | Copyright: 14 | 15 | Copyright (C) 2012-2017 CJSC Flant 16 | 17 | License: 18 | 19 | This program is free software: you can redistribute it and/or modify 20 | it under the terms of the GNU General Public License as published by 21 | the Free Software Foundation, either version 3 of the License, or 22 | (at your option) any later version. 23 | 24 | This package is distributed in the hope that it will be useful, 25 | but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | GNU General Public License for more details. 28 | 29 | You should have received a copy of the GNU General Public License 30 | along with this program. If not, see . 31 | 32 | On Debian systems, the complete text of the GNU General 33 | Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". 34 | 35 | The Debian packaging is: 36 | 37 | Copyright (C) 2012 Nikolay Bogdanov 38 | 39 | # Please chose a license for your packaging work. If the program you package 40 | # uses a mainstream license, using the same license is the safest choice. 41 | # Please avoid to pick license terms that are more restrictive than the 42 | # packaged work, as it may make Debian's contributions unacceptable upstream. 43 | # If you just want it to be GPL version 3, leave the following line in. 44 | 45 | and is licensed under the GPL version 3, see above. 46 | 47 | # Please also look if there are files or directories which have a 48 | # different copyright/license attached and list them here. 49 | -------------------------------------------------------------------------------- /debian/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rt_tables="/etc/iproute2/rt_tables" 4 | if !(cat "$rt_tables"|grep -q netgwm_check) then 5 | echo "194 netgwm_check" >> "$rt_tables" 6 | fi 7 | 8 | invoke-rc.d netgwm start 9 | 10 | -------------------------------------------------------------------------------- /debian/postrm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rt_tables="/etc/iproute2/rt_tables" 4 | if (cat "$rt_tables"|grep -q netgwm_check) then 5 | sed -i '/netgwm_check/d' "$rt_tables" 6 | fi 7 | 8 | -------------------------------------------------------------------------------- /debian/prerm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | invoke-rc.d netgwm stop 4 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | # Sample debian/rules that uses debhelper. 4 | # This file was originally written by Joey Hess and Craig Small. 5 | # As a special exception, when this file is copied by dh-make into a 6 | # dh-make output file, you may use that output file without restriction. 7 | # This special exception was added by Craig Small in version 0.37 of dh-make. 8 | 9 | # Uncomment this to turn on verbose mode. 10 | #export DH_VERBOSE=1 11 | 12 | %: 13 | dh $@ 14 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /netgwm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /etc/default/netgwm 4 | 5 | echo $$ > /var/run/netgwm.pid 6 | 7 | while true; do 8 | /usr/lib/netgwm/netgwm.py 9 | sleep $INTERVAL 10 | done 11 | -------------------------------------------------------------------------------- /netgwm.default: -------------------------------------------------------------------------------- 1 | # Defaults for NetGWM initscript 2 | # sourced by /etc/init.d/netgwm 3 | # installed at /etc/default/netgwm by the maintainer scripts 4 | 5 | # Start service on boot? 6 | START=no 7 | 8 | # Gateway check interval, in seconds 9 | INTERVAL=60 10 | -------------------------------------------------------------------------------- /netgwm.init.d: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: netgwm 4 | # Required-Start: $syslog 5 | # Required-Stop: $syslog 6 | # Should-Start: $network 7 | # Should-Stop: $network 8 | # X-Start-Before: network 9 | # X-Stop-After: network 10 | # Default-Start: 2 3 4 5 11 | # Default-Stop: 1 12 | # Short-Description: runs script for NetGWM (Network Gateway Manager) 13 | ### END INIT INFO 14 | 15 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 16 | DAEMON=/usr/sbin/netgwm 17 | NAME=netgwm 18 | PIDFILE=/var/run/$NAME.pid 19 | DESC="NetGWM (Network Gateway Manager) service" 20 | START=no 21 | DEFAULT_CONFIG=/etc/default/netgwm 22 | 23 | unset TMPDIR 24 | 25 | test -x $DAEMON || exit 0 26 | 27 | . /lib/lsb/init-functions 28 | 29 | . $DEFAULT_CONFIG 30 | 31 | # Get the timezone set. 32 | if [ -z "$TZ" -a -e /etc/timezone ]; then 33 | TZ=`cat /etc/timezone` 34 | export TZ 35 | fi 36 | 37 | case "$1" in 38 | start) 39 | log_begin_msg "Starting $DESC: $NAME" 40 | case "$START" in 41 | "YES"|"Yes"|"yes"|"True"|"TRUE"|"true") 42 | start-stop-daemon --start -b --quiet --pidfile "$PIDFILE" --exec "$DAEMON" && success=1 43 | log_end_msg $? 44 | ;; 45 | *) 46 | echo "" 47 | echo "netgwm not configured to start, see \$START in $DEFAULT_CONFIG" 48 | ;; 49 | esac 50 | ;; 51 | stop) 52 | log_begin_msg "Stopping $DESC: $NAME" 53 | start-stop-daemon --stop --quiet --retry 5 --signal 15 --pidfile $PIDFILE --name $NAME && success=1 54 | rm $PIDFILE 55 | log_end_msg $? 56 | ;; 57 | reload|force-reload) 58 | echo "Error: argument '$1' not supported" >&2 59 | exit 3 60 | ;; 61 | restart) 62 | echo "Error: argument '$1' not supported" >&2 63 | exit 3 64 | ;; 65 | status) 66 | echo -n "Status of $DESC: " 67 | if [ ! -r "$PIDFILE" ]; then 68 | echo "$NAME is not running." 69 | exit 3 70 | fi 71 | if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then 72 | echo "$NAME is running." 73 | exit 0 74 | else 75 | echo "$NAME is not running but $PIDFILE exists." 76 | exit 1 77 | fi 78 | ;; 79 | *) 80 | N=/etc/init.d/${0##*/} 81 | echo "Usage: $N {start|stop|status}" >&2 82 | exit 1 83 | ;; 84 | esac 85 | 86 | exit 0 87 | 88 | -------------------------------------------------------------------------------- /netgwm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # NetGWM (Network Gateway Manager) is a tool for 5 | # automatically switching gateways when Internet 6 | # goes offline. 7 | # 8 | # Home page (Russian): https://flant.ru/projects/netgwm 9 | # 10 | # Copyright (C) 2012-2017 CJSC Flant (www.flant.ru) 11 | # Written by Andrey Polovov 12 | # 13 | # This program is free software; you can redistribute it and/or modify 14 | # it under the terms of the GNU General Public License as published by 15 | # the Free Software Foundation; either version 3 of the License, or 16 | # any later version. 17 | # 18 | # This program is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | # GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with this program. If not, see . 25 | 26 | import sys, os, stat 27 | import yaml 28 | import time 29 | import socket 30 | import optparse 31 | import re 32 | import logging 33 | 34 | configfile = '/etc/netgwm/netgwm.yml' 35 | logfile = '/var/log/netgwm.log' 36 | gwstorefile = '/var/run/netgwm/gwstore.yml' 37 | modefile = '/var/lib/netgwm/mode' 38 | 39 | logging.basicConfig(format = '%(asctime)s %(message)s', filename = logfile, level = logging.INFO) 40 | 41 | def main(): 42 | parser = optparse.OptionParser(add_help_option = False, epilog = 'Home page: http://flant.ru/projects/netgwm') 43 | parser.add_option('-h', '--help', action = 'help', help = 'display this help and exit') 44 | parser.add_option('-c', '--config', default = configfile, help = 'full path to NetGWM configuration file') 45 | options, args = parser.parse_args() 46 | 47 | if not os.path.isfile(options.config): 48 | parser.error('Config file (%s) not found.' % options.config) 49 | 50 | config = yaml.load(open(options.config, 'r')) 51 | if not os.path.exists('/var/run/netgwm/'): os.mkdir('/var/run/netgwm/') 52 | 53 | try: gwstore = yaml.load(open(gwstorefile, 'r')) 54 | except: gwstore = {} 55 | 56 | gateways = [] 57 | if 'gateways' in config and not config['gateways'] is None: 58 | for gw_identifier, gw_data in config['gateways'].iteritems(): 59 | gateways.append(GatewayManager(gwstore, identifier=gw_identifier, **gw_data)) 60 | 61 | currentgw = GatewayManager.get_current_gateway(gateways) 62 | 63 | try: 64 | if 'mode' in config: mode = config['mode'] 65 | else: mode = open(modefile, 'r').read().strip() 66 | if mode not in config['gateways']: raise Exception() 67 | except: mode = 'auto' 68 | 69 | if mode == 'auto': 70 | if currentgw is not None and currentgw.check(config['check_sites']): 71 | # If Internet is available... 72 | # Looking for a gateway with a higher priority (higher than current one) 73 | candidates = [x for x in gateways if x.priority < currentgw.priority] 74 | for gw in sorted(candidates, key = lambda x: x.priority): 75 | if gw.check(config['check_sites']) and gw.wakeuptime < (time.time() - config['min_uptime']): 76 | # This router works and is stable enough 77 | gw.setdefault() 78 | post_replace_trigger(newgw=gw, oldgw=currentgw) 79 | break 80 | else: continue 81 | else: 82 | # Switching to a gateway having highest priority 83 | for gw in sorted(gateways, key = lambda x: x.priority): 84 | if gw == currentgw: continue # Our current gateway doesn't work 85 | if gw.check(config['check_sites']): 86 | gw.setdefault() 87 | post_replace_trigger(newgw=gw, oldgw=currentgw) 88 | break 89 | else: continue 90 | # What a pity! No gateway works :( 91 | else: 92 | fixedgw = [x for x in gateways if x.identifier == mode].pop() 93 | if currentgw is None or currentgw != fixedgw: 94 | fixedgw.setdefault() 95 | post_replace_trigger(newgw=fixedgw, oldgw=currentgw) 96 | 97 | if 'check_all_gateways' in config and config['check_all_gateways'] is True: 98 | for gw in [x for x in gateways if not x.is_checked]: gw.check(config['check_sites']) 99 | 100 | GatewayManager.store_gateways(gateways) 101 | 102 | 103 | def post_replace_trigger(newgw, oldgw): 104 | # post-replace.d 105 | args = [] 106 | args.append(newgw.identifier) 107 | args.append(newgw.ip if hasattr(newgw, 'ip') else 'NaN') 108 | args.append(newgw.dev if hasattr(newgw, 'dev') else 'NaN') 109 | args.append(oldgw.identifier if not oldgw is None else 'Nan') 110 | args.append(oldgw.ip if not oldgw is None and hasattr(oldgw, 'ip') else 'NaN') 111 | args.append(oldgw.dev if not oldgw is None and hasattr(oldgw, 'dev') else 'NaN') 112 | for filename in sorted(os.listdir('/etc/netgwm/post-replace.d/')): 113 | execpath = '/etc/netgwm/post-replace.d/'+filename 114 | if os.path.isfile(execpath) and (os.stat(execpath).st_mode & stat.S_IXUSR): 115 | os.system(execpath+' '+' '.join(args)) 116 | 117 | 118 | class GatewayManager: 119 | def __init__(self, gwstore, **kwargs): 120 | self.priority = kwargs['priority'] 121 | self.identifier = kwargs['identifier'] 122 | self.is_checked = False 123 | if 'ip' in kwargs and kwargs['ip'] is not None: self.ip = kwargs['ip'] 124 | if 'dev' in kwargs and kwargs['dev'] is not None: self.dev = kwargs['dev'] 125 | 126 | if self.identifier in gwstore: self.wakeuptime = gwstore[self.identifier]['wakeuptime'] 127 | else: self.wakeuptime = 0 # When a gateway appears for the first time, its uptime is set to something BIG 128 | 129 | def __eq__(self, other): 130 | if other is None: return False 131 | else: return self.identifier == other.identifier 132 | 133 | def check(self, check_sites): 134 | # Checking gateway status 135 | print 'checking ' + self.identifier 136 | ipresult = not os.system('/sbin/ip route replace default %s table netgwm_check' % self.generate_route()) 137 | 138 | if ipresult is True: 139 | for site in check_sites: 140 | try: 141 | site_ip = socket.gethostbyname(site) 142 | 143 | os.system('/sbin/ip rule add iif lo to %s lookup netgwm_check' % site_ip) 144 | 145 | p = os.popen('ping -q -n -W 1 -c 2 %s 2> /dev/null' % site_ip) 146 | pingout = p.read() 147 | status = not p.close() 148 | 149 | os.system('/sbin/ip rule del iif lo to %s lookup netgwm_check' % site_ip) 150 | 151 | if status is True: 152 | # Ping has been successful 153 | rtt = re.search('\d+\.\d+/(\d+\.\d+)/\d+\.\d+/\d+\.\d+', pingout).group(1) 154 | info = 'up:'+site+':'+rtt 155 | break 156 | else: 157 | # Ping has failed 158 | info = 'down' 159 | 160 | except: 161 | status = False 162 | 163 | os.system('/sbin/ip route del default %s table netgwm_check' % self.generate_route()) 164 | else: 165 | status = False 166 | info = 'down' 167 | 168 | try: 169 | with open('/var/run/netgwm/'+self.identifier, 'w') as f: f.write(info) 170 | except: pass 171 | 172 | if self.wakeuptime is None and status is True: self.wakeuptime = time.time() # Setting wakeup time if it's not set and server works (has answered to a ping) 173 | elif status is False: self.wakeuptime = None # Removing wakeup time if server doesn't work (no ping) 174 | 175 | self.is_checked = True 176 | 177 | return status 178 | 179 | def setdefault(self): 180 | # Replacing route 181 | print '/sbin/ip route replace default ' + self.generate_route() 182 | os.system('/sbin/ip route replace default ' + self.generate_route()) 183 | logging.info('route replaced to: %s', self.generate_route()) 184 | 185 | def generate_route(self): 186 | res = [] 187 | if hasattr(self, 'ip'): res.append('via ' + self.ip) 188 | if hasattr(self, 'dev'): res.append('dev ' + self.dev) 189 | return ' '.join(res) 190 | 191 | @staticmethod 192 | def get_current_gateway(gateways): 193 | currentgw_ip = os.popen("/sbin/ip route | grep 'default via' | sed -r 's/default via (([0-9]+\.){3}[0-9]+) dev .+/\\1/g'").read().strip() 194 | currentgw_dev = os.popen("/sbin/ip route | grep 'default dev' | sed -r 's/default dev ([a-z0-9]+)(\s+.*)?/\\1/g'").read().strip() 195 | 196 | if currentgw_ip == '' and currentgw_dev == '': 197 | return None 198 | elif currentgw_ip != '': 199 | for g in [x for x in gateways if hasattr(x, 'ip')]: 200 | if g.ip == currentgw_ip: return g 201 | elif currentgw_dev != '': 202 | for g in [x for x in gateways if hasattr(x, 'dev')]: 203 | if g.dev == currentgw_dev: return g 204 | else: raise Exception('current gw is not listed in config.') 205 | 206 | @staticmethod 207 | def store_gateways(gateways): 208 | gwstore = {} 209 | for gw in gateways: gwstore[gw.identifier] = {'wakeuptime': gw.wakeuptime} 210 | open(gwstorefile, 'w').write(yaml.dump(gwstore)) 211 | 212 | 213 | if __name__ == '__main__': 214 | main() 215 | -------------------------------------------------------------------------------- /samples/netgwm.yml: -------------------------------------------------------------------------------- 1 | # Default configuration file for NetGWM 2 | 3 | # This file should be placed as /etc/netgwm/netgwm.yml 4 | # Otherwise, you should run netgwm.py with -c argument 5 | 6 | gateways: # IPs or devices for gateways with corresponding 7 | # priorities (value "1" is for the primary 8 | # gateway, "2" -- for the second, and so on) 9 | thebestone: {ip: 42.42.42.42, priority: 1} 10 | notsogood: {ip: 42.84.168.42, priority: 2} 11 | gprsbackup: {dev: ppp333, priority: 3} 12 | 13 | # Minimum time to consider gateway as working, in seconds 14 | min_uptime: 900 # 15 min 15 | 16 | # Network addresses (IPs or domains) used for checking 17 | # gateways status. Ping packets will be sent to these 18 | # addresses through a gateway. If all of them are 19 | # unavailable, the gateway is considered as gone offline 20 | check_sites: 21 | - 8.8.4.4 # Google public DNS 22 | - 4.2.2.2 # Verizon public DNS 23 | - something.in.the.wheel.com 24 | 25 | # Should NetGWM check all the gateways every time? 26 | # Disabled by default, used in very special cases only 27 | check_all_gateways: false 28 | -------------------------------------------------------------------------------- /samples/post-replace.d/conntrack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Warning! This script should be placed in the 4 | # /etc/netgwm/post-replace.d/ directory to work. 5 | # 6 | # With default route changing, TCP connections 7 | # are reset but UDP streams are not. It leads to 8 | # some (UDP related) network services (Asterisk, 9 | # etc) trying to send packages via the outdated 10 | # (not currently working) gateway. 11 | 12 | conntrack -D -p udp 13 | -------------------------------------------------------------------------------- /samples/post-replace.d/script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Warning! This script should be placed in the 4 | # /etc/netgwm/post-replace.d/ directory to work. 5 | # 6 | # All the scripts placed in post-replace.d are 7 | # executed every time NetGWM changes the current 8 | # network gateway. In these scripts, you can use 9 | # the following arguments: 10 | # 11 | # $1 - new gateway identifier 12 | # $2 - new gateway IP or NaN 13 | # $3 - new gateway device or NaN 14 | # $4 - old gateway identifier or NaN 15 | # $5 - old gateway IP or NaN 16 | # $6 - old gateway device or NaN 17 | -------------------------------------------------------------------------------- /samples/rt_tables.sample: -------------------------------------------------------------------------------- 1 | # This file is an example from default NetGWM installation 2 | # It should be named rt_tables and placed to your iproute 3 | # configuration directory: /etc/iproute2 4 | # 5 | # reserved values 6 | # 7 | 255 local 8 | 254 main 9 | 253 default 10 | 0 unspec 11 | # 12 | # local 13 | # 14 | #1 inr.ruhep 15 | 16 | # This table is used by NetGWM (please check https://flant.ru/projects/netgwm 17 | # to learn more details from Russian language documentation) 18 | 100 netgwm_check 19 | --------------------------------------------------------------------------------