Skip to content

Instantly share code, notes, and snippets.

@timurvafin
Created August 23, 2010 11:48
Show Gist options
  • Save timurvafin/545319 to your computer and use it in GitHub Desktop.
Save timurvafin/545319 to your computer and use it in GitHub Desktop.
## update_iptables
dir=`dirname $0`
dir=`readlink -f $dir`
update_iptables_config() {
mv -f /etc/sysconfig/iptables /etc/sysconfig/iptables.`date +%F`
ip=`/sbin/ifconfig $1 | sed -n "/^[A-Za-z0-9]/ {N;/dr:/{;s/.*dr://;s/ .*//;p;}}"`
cat $dir/iptables.base | sed "s/EXTERNAL_DEV/$1/" | sed "s/EXTERNAL_IP/$ip/" > /etc/sysconfig/iptables
cat /etc/sysconfig/iptables | /sbin/iptables-restore
}
update_iptables_config $1
## adsl-lost
#!/bin/bash
sh /home/admin/tools-local/network_switch/update_iptables `/sbin/ifconfig | grep 78.138 -B 2 | grep Link | awk '{ print $1 }'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment