Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- echo -n "Firewall name: "
- read fwname
- echo -n "Domain name: "
- read dname
- echo -n "Password: "
- read password
- echo -n "eth0 speed (10/100/auto): "
- read eth0speed
- echo -n "eth1 speed (10/100/auto): "
- read eth1speed
- echo "1. Linux"
- echo "2. Windows"
- echo "3. Exit"
- echo -n "Please select an operating system: "
- read OS
- if [ $OS == 1 ]; then
- OS="lin"
- elif [ $OS == 2 ]; then
- OS="win"
- elif [ $OS == 2 ]; then
- exit
- else
- echo "No OS specified, exiting"
- exit
- fi
- conf_file="$fwname.$dname"
- touch $conf_file
- echo -n "Firewall IP: "
- read fwip
- echo -n "Default gateway: "
- read gw
- echo "enable" >> $conf_file
- echo "configure terminal" >> $conf_file
- echo "interface ethernet0 $eth0speed"full >> $conf_file
- echo "interface ethernet1 $eth1speed"full >> $conf_file
- echo "enable password $password" encrypted >> $conf_file
- echo "passwd $password" encrypted >> $conf_file
- echo "hostname $fwname" >> $conf_file
- echo "domain-name $dname" >> $conf_file
- echo "" >> $conf_file
- echo "fixup protocol ftp 21" >> $conf_file
- echo "fixup protocol h323 h225 1720" >> $conf_file
- echo "fixup protocol h323 ras 1718-1719" >> $conf_file
- echo "fixup protocol http 80" >> $conf_file
- echo "fixup protocol rsh 514" >> $conf_file
- echo "fixup protocol rtsp 554" >> $conf_file
- echo "fixup protocol sip 5060" >> $conf_file
- echo "fixup protocol sip udp 5060" >> $conf_file
- echo "fixup protocol skinny 2000" >> $conf_file
- echo "fixup protocol smtp 25" >> $conf_file
- echo "fixup protocol sqlnet 1521" >> $conf_file
- echo "fixup protocol tftp 69" >> $conf_file
- echo "" >> $conf_file
- echo "names" >> $conf_file
- echo "name $fwip $fwname" >> $conf_file
- echo "name "$gw" DefaultGateway" >> $conf_file
- echo "name 192.168.0.1" "$fwname-inside" >> $conf_file
- declare -i TOT_IP
- declare -a IP
- read -p "Number of external IP's on the server: " TOT_IP
- for i in $(seq 1 $TOT_IP)
- do
- read -p "$i. Specify IP: " IP[$i]
- done
- let i=1
- for IP in ${IP[*]}
- do
- let intip=i+1
- echo "name" $IP EXT-IP-"$i" >> $conf_file
- echo "name" 192.168.0."$intip" INT-IP-"$i" >> $conf_file
- let i=i+1
- done
- echo "" >> $conf_file
- echo -n "Do specific remote users require access to certain ports? (y/n) "
- read SPECUSERS
- if [ $SPECUSERS == y ]; then
- echo "" >> $conf_file
- echo "object-group network customer_specified" >> $conf_file
- echo -n "How many users are required? "
- read USERS
- COUNT=$(eval "echo {1..$USERS}")
- for i in $COUNT
- do
- read -p "Specify remote IP address: " IPS[$i]
- done
- for IP in ${IPS[*]}
- do
- echo "network-object" "$IP" "255.255.255.255" >> $conf_file
- done
- fi
- echo "access-list inbound remark Allow ICMP inbound" >> $conf_file
- echo "access-list inbound permit icmp any any echo" >> $conf_file
- echo "access-list inbound permit icmp any any traceroute" >> $conf_file
- echo "access-list inbound permit icmp any any echo-reply" >> $conf_file
- echo "access-list inbound remark Allow HTTP access" >> $conf_file
- COUNT=$(eval "echo {1..$TOT_IP}")
- for i in $COUNT
- do
- echo "access-list inbound permit tcp any host" EXT-IP-"$i" eq www >> $conf_file
- done
- echo "access-list inbound remark Allow HTTPS access" >> $conf_file
- COUNT=$(eval "echo {1..$TOT_IP}")
- for i in $COUNT
- do
- echo "access-list inbound permit tcp any host" EXT-IP-"$i" eq https >> $conf_file
- done
- echo "access-list inbound remark Allow SMTP access" >> $conf_file
- COUNT=$(eval "echo {1..$TOT_IP}")
- for i in $COUNT
- do
- echo "access-list inbound permit tcp any host" EXT-IP-"$i" eq smtp >> $conf_file
- done
- echo "access-list inbound remark Allow DNS access" >> $conf_file
- COUNT=$(eval "echo {1..$TOT_IP}")
- for i in $COUNT
- do
- echo "access-list inbound permit tcp any host" EXT-IP-"$i" eq domain >> $conf_file
- echo "access-list inbound permit udp any host" EXT-IP-"$i" eq domain >> $conf_file
- done
- echo "access-list inbound remark Allow FTP access" >> $conf_file
- COUNT=$(eval "echo {1..$TOT_IP}")
- for i in $COUNT
- do
- echo "access-list inbound permit tcp any host" EXT-IP-"$i" eq ftp >> $conf_file
- echo "access-list inbound permit tcp any host" EXT-IP-"$i" eq ftp-data >> $conf_file
- done
- if [ $OS == win ]; then
- echo "access-list inbound remark Allow Remote Desktop access" >> $conf_file
- COUNT=$(eval "echo {1..$TOT_IP}")
- for i in $COUNT
- do
- echo "access-list inbound permit tcp any host EXT-IP-"$i" eq 3389" >> $conf_file
- done
- fi
- if [ $OS == lin ]; then
- echo "access-list inbound remark Allow SSH access" >> $conf_file
- COUNT=$(eval "echo {1..$TOT_IP}")
- for i in $COUNT
- do
- echo "access-list inbound permit tcp any host EXT-IP-"$i" eq 23" >> $conf_file
- done
- fi
- declare -i NUM_PORTS
- declare -a PORTS
- echo "The Following ports are opened by default"
- echo "PORT Service"
- echo " 80 WWW"
- echo " 21 FTP"
- echo " 443 HTTPS"
- echo " 25 SMTP"
- echo " 53 DNS"
- if [ $OS == lin ]; then
- echo " 23 SSH"
- elif [ $OS == win ]; then
- echo " 3389 Remote Desktop"
- fi
- echo
- read -p "Do you need to open a port range? (y/n) " RANGE
- if [ $RANGE == "y" ]
- then
- echo "access-list inbound remark additional range (customer req)" >> $conf_file
- echo -n "Do only the users specified earlier require access to this port range? (y/n) "
- read SPECS
- if [ $SPECS == "y" ]
- then
- read -p "From port: " RANGE1
- read -p "To port: " RANGE2
- EXTIP=$(eval "echo {1..$TOT_IP}")
- for i in $EXTIP
- do
- echo "access-list inbound permit tcp object-group customer_specified EXT-IP-""$i" "range" "$RANGE1" "$RANGE2" >> $conf_file
- done
- else
- read -p "From port: " RANGE1
- read -p "To port: " RANGE2
- EXTIP=$(eval "echo {1..$TOT_IP}")
- for i in $EXTIP
- do
- echo "access-list inbound permit tcp any host EXT-IP-""$i" "range" "$RANGE1" "$RANGE2" >> $conf_file
- done
- fi
- fi
- read -p "How many additional ports do you want to open? (type 0 to skip) " NUM_PORTS
- if [ $NUM_PORTS -gt "0" ]
- then
- echo "access-list outbound remark additional ports (customer req)" >> $conf_file
- COUNT=$(eval "echo {1..$NUM_PORTS}")
- for i in $COUNT
- do
- read -p "$i. specify port: " PORTS[$i]
- done
- for port in ${PORTS[*]}
- do
- echo -n "Is access to port" "$port" "limited to the users specified previously? (y/n)"
- read SPECS
- EXTIP=$(eval "echo {1..$TOT_IP}")
- for i in $EXTIP
- do
- if [ $SPECS == "y" ]
- then
- echo "access-list inbound permit tcp object-group customer_specified EXT-IP-""$i" eq "$port" >> $conf_file
- else
- echo "access-list inbound permit tcp any host EXT-IP-""$i" eq "$port" >> $conf_file
- fi
- done
- done
- fi
- echo "access-list inbound deny ip any any" >> $conf_file
- echo "access-list outbound remark" >> $conf_file
- echo "access-list outbound permit ip any any" >> $conf_file
- echo "pager lines 24" >> $conf_file
- echo "logging on" >> $conf_file
- echo "logging timestamp" >> $conf_file
- echo "logging buffered warnings" >> $conf_file
- echo "icmp permit any echo-reply outside" >> $conf_file
- echo "icmp permit any echo outside" >> $conf_file
- echo "icmp deny any outside" >> $conf_file
- echo "icmp permit any inside" >> $conf_file
- echo "mtu outside 1500" >> $conf_file
- echo "mtu inside 1500" >> $conf_file
- echo "ip address outside" "$fwname" "255.255.254.0" >> $conf_file
- echo "ip address inside" "$fwname-inside" "255.255.255.0" >> $conf_file
- echo "ip audit info action alarm" >> $conf_file
- echo "ip audit attack action alarm" >> $conf_file
- echo "no pdm history enable" >> $conf_file
- echo "arp timeout 14400" >> $conf_file
- echo "global (outside) 1 interface" >> $conf_file
- echo "nat (inside) 1 0.0.0.0 0.0.0.0 0 0" >> $conf_file
- COUNT=$(eval "echo {1..$TOT_IP}")
- for i in $COUNT
- do
- echo "static" "(inside,outside)" "EXT-IP-$i" "INT-IP-$i" "netmask 255.255.255.255 0 0" >> $conf_file
- done
- echo "access-group inbound in interface outside" >> $conf_file
- echo "access-group outbound in interface inside" >> $conf_file
- echo "route outside 0.0.0.0 0.0.0.0 DefaultGateway 1" >> $conf_file
- echo "timeout xlate 3:00:00" >> $conf_file
- echo "timeout conn 12:00:00 half-closed 6:00:00 udp 0:02:00 rpc 0:10:00 h225 1:00:00" >> $conf_file
- echo "timeout h323 0:05:00 mgcp 0:05:00 sip 0:30:00 sip_media 0:02:00" >> $conf_file
- echo "timeout sip-disconnect 0:02:00 sip-invite 0:03:00" >> $conf_file
- echo "timeout uauth 0:05:00 absolute" >> $conf_file
- echo "aaa-server TACACS+ protocol tacacs+" >> $conf_file
- echo "aaa-server TACACS+ max-failed-attempts 3" >> $conf_file
- echo "aaa-server TACACS+ deadtime 10" >> $conf_file
- echo "aaa-server RADIUS protocol radius" >> $conf_file
- echo "aaa-server RADIUS max-failed-attempts 3" >> $conf_file
- echo "aaa-server RADIUS deadtime 10" >> $conf_file
- echo "aaa-server LOCAL protocol local" >> $conf_file
- echo "http server enable" >> $conf_file
- echo "no snmp-server location" >> $conf_file
- echo "no snmp-server contact" >> $conf_file
- echo "snmp-server community public" >> $conf_file
- echo "no snmp-server enable traps" >> $conf_file
- echo "floodguard enable" >> $conf_file
- echo "telnet timeout 20" >> $conf_file
- echo "ssh 0.0.0.0 0.0.0.0 outside" >> $conf_file
- echo "ssh 0.0.0.0 0.0.0.0 inside" >> $conf_file
- echo "ssh timeout 60" >> $conf_file
- echo "console timeout 60" >> $conf_file
- echo "username admin password $password encrypted privilege 2" >> $conf_file
- echo "terminal width 80" >> $conf_file
- echo "write mem" >> $conf_file
- clear
- echo "File generated named" "$fwname"."$dname" "paste this config onto the firewall."
- echo "Setup the server with the following settings:"
- COUNT=$(eval "echo {1..$TOT_IP}")
- for i in $COUNT
- do
- let intip=i+1
- echo "IP: "192.168.0."$intip"
- let i=i+1
- done
- echo "Subnet mask: 255.255.255.0"
- echo "Default gateway: 192.168.0.1"
Advertisement
Add Comment
Please, Sign In to add comment