[root@dywH ~]# cd /usr/src/nat/bin [root@dywH bin]# vim natboot.sh passwd passwd csielabnat
[root@dywH bin]# vim natboot.sh ethdhcp='eth0' ## Internal Network ethint='eth1' ## External Network answer="n" echo -n "SETUP EXTERNAL NETWORK: " while [ x"$answer" != "xy" ] && [ x"$answer" != "xY" ] ; do echo -n "enter ip: "; read ip echo -n "enter netmask (255.255.255.0): "; read netmask [ "$netmask" == "" ] && netmask='255.255.255.0' echo -n "enter default gw: "; read gw echo echo You entered: echo -e "\tip: $ip" echo -e "\tnetmask: $netmask" echo -e "\tdefault gw: $gw" echo -n "Is this correct? [y/n] "; read answer done
[root@dywH bin]# vim natboot.sh cat > /etc/sysconfig/network-scripts/ifcfg-eth1 << END DEVICE='eth1' BOOTPROTO='static' NM_CONTROLLED=no ONBOOT=yes IPADDR=$ip NETMASK=$netmask GATEWAY=$gw DNS1=163.17.3.1 DNS2=163.17.1.1 END
/etc/init.d/network restart
--set= 後接 open 為全開放、 close 為全關閉、csie 為只開放連上校內網路、dywang 為只能連上 De-Yu Wang 指定的網站。若此參數不輸入,預設為全開放。myip 可以單獨指定某 ip 完全放行,不受防火牆管制。
[root@dywH bin]# vim natboot.sh
answer="n"
echo -n "SETUP IPTABLES: "
while [ x"$answer" != "xy" ] && [ x"$answer" != "xY" ] ; do
echo -n "enter myip: "; read ip
myip="192.168.1.$ip"
echo -n "enter --set=[open|close|csie|dywang]: "; read iptab
[ "$iptab" == "" ] && iptab=” || iptab="--set=${iptab}"
echo
echo You entered:
echo -e "\tmyip: $myip"
echo -e "\tiptables : $iptab"
echo -n "Is this correct? [y/n] "; read answer
done
[root@dywH bin]# vim natboot.sh setdhcpiptables.sh $iptab --myip=$myip exit 0 %post --nochroot --log=$INSTALL_ROOT/tmp/ksnochrootpost cp /usr/src/nat/bin/*.sh $INSTALL_ROOT/usr/local/bin/ %end