Useful Bash Script

Posted: January 24, 2008 in Linux, Networking, Tutor

hehehe waktu itu iseng chat ama iqbal trs dia ngunjukin sitenye, and gw liat ada bash script, setelah gw baca n gw liat2 hmm very2 nice script… simple but powerfull i said in my mind :D, hehehe krn dr script itu gw jd bs buat script2 yg laen, mantaph om iqbal, emang cocok deh dikasih julukan muke console 😀 :D, oh iya ga lupa gw cantumin scriptnya :

################
#!/bin/sh #
#171207 #
#Script Adduser#
################

echo -n “Masukkan Username = “;
read nama
echo -n “Masukkan Nama Lengkap = “;
read namalengkap

echo “Add User”
/usr/sbin/useradd -c”$namalengkap” $nama
echo “Masukkan Password 2x yah..”
/usr/bin/passwd $nama

———————–
#######################
#!/bin/sh #
#171207 #
#Script Add IP Address#
#######################

echo “Example Interface = eth0″;
echo -n “Interface = “;
read interface
echo -n “Masukkan IP Address = “;
read ip
echo -n “Masukkan Subnetmask = “;
read subnetmask
echo -n “Masukkan Default Gateway = “;
read gateway
echo -n “Masukkan DNS Server = “;
read dns

echo “Add IP Address”;
/sbin/ifconfig -a $interface $ip $netmask

echo “Add Default Gateway”;
/sbin/route add default gw $gateway

echo “Add DNS Server”;
echo “nameserver $dns” > /etc/resolv.conf

——————————
##############################
#!/bin/sh #
#171207 #
#Script Add Virtual Interface#
##############################

echo “Example Interface Virtual = eth0:1″;
echo -n “Interface Virtual= “;
read interface
echo -n “Masukkan IP Address = “;
read ip
echo -n “Masukkan Subnetmask = “;
read subnetmask

echo “Add Interface Virtual”
/bin/touch /etc/sysconfig/network-scripts/ifcfg-$interface
echo “DEVICE=$interface” >> /etc/sysconfig/network-scripts/ifcfg-$interface
echo “ONBOOT=yes” >> /etc/sysconfig/network-scripts/ifcfg-$interface
echo “BOOTPROTO=static” >> /etc/sysconfig/network-scripts/ifcfg-$interface
echo “IPADDR=$ip” >> /etc/sysconfig/network-scripts/ifcfg-$interface
echo “NETMASK=$subnetmask” >> /etc/sysconfig/network-scripts/ifcfg-$interface

echo “Restart Service Network”;
/etc/init.d/network restart

———————————–
###################################
#!/bin/sh #
#171207 #
#Script Transparant Proxy #
###################################

echo -n “Masukkan source ‘IP/NETMASK’ =”;
read source
echo -n “Masukkan Destination ‘IP/NETMASK’ =”;
read destination
echo -n “Masukkan Protocol =”;
read protocol
echo -n “Masukkan Destination Port =”;
read dport
echo -n “Masukkan Redirect Port =”;
read redirect

echo “Create redirect rule”

/sbin/iptables -t nat -I PREROUTING -s $source -d $destination -p $protocol –dport $dport -j REDIRECT –to-port $redirect
/sbin/iptables -t nat -I POSTROUTING -s $source -o etho -j MASQUERADE

taken from : http://otakudang.maker-it.org/?p=15

mantap bal, gw ijin kupipes yeee buat arsip, sapa tau server lo keabisan benwit 😀 😀

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s