Last active
February 10, 2016 16:29
-
-
Save renier/e6116f3605defc6bc6ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!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