Skip to content

Instantly share code, notes, and snippets.

@starlocke
Created February 11, 2016 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save starlocke/aa69af01fed512c1e3be to your computer and use it in GitHub Desktop.
Save starlocke/aa69af01fed512c1e3be to your computer and use it in GitHub Desktop.
Small python script template to get current system to lock on to a particular load balance server; must be customized for target hosts
#!/usr/bin/python
import os
import sys
if len(sys.argv) < 2:
print 'Usage: load [a|b|c]'
raise SystemExit()
if sys.argv[1] == 'a':
ip = '203.0.113.1'
if sys.argv[1] == 'b':
ip = '203.0.113.2'
if sys.argv[1] == 'c':
ip = '203.0.113.3'
if not ip:
print 'Param must be: a|b|c'
raise SystemExit()
host = 'www.example.com'
cmd = 'sed -i "s|.*' +host+ '|' +ip+ ' ' +host+ '|g"'
target = '/etc/hosts'
## Example command, expanded out ##
# sed -i "s|.*www.example.com|203.0.113.1 www.example.com|g" /etc/hosts
os.system(cmd + ' ' + target)
@starlocke
Copy link
Author

https://sites.google.com/site/sudokillall9/articles/lockingontoloadbalancers

  • I currently think that curl is somewhat sweeter than using this to try to get a browser to hit certain load balance servers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment