Skip to content

Instantly share code, notes, and snippets.

@renier
Last active February 10, 2016 16:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save renier/e6116f3605defc6bc6ba to your computer and use it in GitHub Desktop.
Save renier/e6116f3605defc6bc6ba to your computer and use it in GitHub Desktop.
#!ruby
if ENV['USER'] != 'root'
puts "I need to run with sudo!"
exit(1)
end
bad_rule = 'deny ip from any to any'
rule_id = nil
rules = `ipfw list`.split(/\n/)
rules.each do |rule|
if rule.index(bad_rule)
rule_id = rule.split(/ /).first
break
end
end
if rule_id.nil?
puts "Bad rule was not found. Carry on."
exit(0)
end
`ipfw delete #{rule_id}`
puts 'Removed bad rule.'
# The network here could be a parameter to the script as well as the interface,
# but for now it's ok.
`route add 192.168.50.0/24 -interface vboxnet2`
`route add 192.168.59.0/24 -interface vboxnet4`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment