Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- banHost="www.example.com"
- function isRoot() {
- me=`id -u`
- root=`id -u root`
- if [ $me -ne $root ]; then
- echo root permission required.
- return 0
- else
- return 1
- fi
- }
- function on() {
- cmd="ipfw -q add"
- ks="keep-state"
- $cmd 1 check-state
- # Flush all rules
- ipfw -q flush
- $cmd 1 deny all from any to $banHost out setup $ks
- }
- function off() {
- cmd="ipfw -q delete"
- $cmd 1
- }
- function firewall() {
- case $1 in
- 'on' )
- on
- ;;
- 'off' )
- off
- ;;
- esac
- }
- isRoot
- if [ $? -eq 0 ]; then
- exit
- else
- if [ -z $1 ]; then
- echo "toggle_net.sh [on | off]"
- exit
- fi
- firewall $1
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement