Skip to content

Instantly share code, notes, and snippets.

@paulosuzart
Created June 23, 2010 19:41
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 paulosuzart/450438 to your computer and use it in GitHub Desktop.
Save paulosuzart/450438 to your computer and use it in GitHub Desktop.
from fabric.operations import sudo, local
from fabric.api import env, settings
from fabric.context_managers import cd
env.cwd = '/home/user'
def _switch_resolv():
with cd('/etc'):
local('sudo rm resolv.conf')
local('sudo cp resolv.tmp.conf resolv.conf')
def routes(dev1='eth1', dev2='eth0', gateway='10.1.0.1'):
""" -> Remove a rota default, adiciona o gateway correto e as rotas.
Depois deve copiar um novo resolv.conf para o /etc """
local('sudo route del default')
local('sudo route add default gateway %s netmask 0.0.0.0 dev %s' % (gateway, dev1))
with settings(warn_only=True):
for ip in ['172.21.0.0', '171.22.0.0', '172.27.0.0']:
local('sudo route add -net %s netmask 255.255.0.0 dev %s' % (ip, dev2))
_switch_resolv()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment