Tuesday, July 13, 2010

Apache intranet proxy server

— SkyHi @ Tuesday, July 13, 2010

What other functions are useful for an intranet proxy server?

An Apache proxy server situated in an intranet needs to forward external requests through the company's firewall (for this, configure the ProxyRemote directive to forward the respective scheme to the firewall proxy). However, when it has to access resources within the intranet, it can bypass the firewall when accessing hosts. The NoProxy directive is useful for specifying which hosts belong to the intranet and should be accessed directly.
Users within an intranet tend to omit the local domain name from their WWW requests, thus requesting "http://somehost/" instead of "http://somehost.my.dom.ain/". Some commercial proxy servers let them get away with this and simply serve the request, implying a configured local domain. When the ProxyDomain directive is used and the server is configured for proxy service, Apache can return a redirect response and send the client to the correct, fully qualified, server address. This is the preferred method since the user's bookmark files will then contain fully qualified hosts.

ProxyRequests directive

Syntax: ProxyRequests on|off
Default: ProxyRequests Off
Context: server config, virtual host
Override: Not applicable
Status: Base
Module: mod_proxy
Compatibility: ProxyRequests is only available in Apache 1.1 and later. This allows or prevents Apache from functioning as a forward proxy server. Setting ProxyRequests to 'off' does not disable use of the ProxyPass directive.
Warning: Do not enable proxying until you have secured your server. Open proxy servers are dangerous both to your network and to the Internet at large.

ProxyRemote directive

Syntax: ProxyRemote match remote-server
Default: None
Context: server config, virtual host
Override: Not applicable
Status: Base
Module: mod_proxy
Compatibility: ProxyRemote is only available in Apache 1.1 and later. This defines remote proxies to this proxy. match is either the name of a URL-scheme that the remote server supports, or a partial URL for which the remote server should be used, or '*' to indicate the server should be contacted for all requests. remote-server is a partial URL for the remote server. Syntax:
remote-server = protocol://hostname[:port]
protocol is the protocol that should be used to communicate with the remote server; only "http" is supported by this module. Example:
ProxyRemote http://goodguys.com/ http://mirrorguys.com:8000
  ProxyRemote * http://cleversite.com
  ProxyRemote ftp http://ftpproxy.mydomain.com:8080
In the last example, the proxy will forward FTP requests, encapsulated as yet another HTTP proxy request, to another proxy which can handle them.

ProxyPass directive

Syntax: ProxyPass path url
Default: None
Context: server config, virtual host
Override: Not applicable
Status: Base
Module: mod_proxy
Compatibility: ProxyPass is only available in Apache 1.1 and later. This directive allows remote servers to be mapped into the space of the local server; the local server does not act as a proxy in the conventional sense, but appears to be a mirror of the remote server. path is the name of a local virtual path; url is a partial URL for the remote server.
Suppose the local server has address http://wibble.org/; then
ProxyPass /mirror/foo/ http://foo.com/
will cause a local request for the <http://wibble.org/mirror/foo/bar> to be internally converted into a proxy request to <http://foo.com/bar>.
Warning: The ProxyRequests directive should usually be set off when using ProxyPass.

ProxyPassReverse directive

Syntax: ProxyPassReverse path url
Default: None
Context: server config, virtual host
Override: Not applicable
Status: Base
Module: mod_proxy
Compatibility: ProxyPassReverse is only available in Apache 1.3b6 and later. This directive lets Apache adjust the URL in the Location header on HTTP redirect responses. For instance this is essential when Apache is used as a reverse proxy to avoid by-passing the reverse proxy because of HTTP redirects on the backend servers which stay behind the reverse proxy.
path is the name of a local virtual path.
url is a partial URL for the remote server - the same way they are used for the ProxyPass directive.
Example:
Suppose the local server has address http://wibble.org/; then
ProxyPass         /mirror/foo/ http://foo.com/
   ProxyPassReverse  /mirror/foo/ http://foo.com/
will not only cause a local request for the <http://wibble.org/mirror/foo/bar> to be internally converted into a proxy request to <http://foo.com/bar> (the functionality ProxyPass provides here). It also takes care of redirects the server foo.com sends: when http://foo.com/bar is redirected by him to http://foo.com/quux Apache adjusts this to http://wibble.org/mirror/foo/quux before forwarding the HTTP redirect response to the client. Note that this ProxyPassReverse directive can also be used in conjunction with the proxy pass-through feature ("RewriteRule ... [P]") from mod_rewrite because its doesn't depend on a corresponding ProxyPass directive.


#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.

ServerName      siva.example.com
DocumentRoot    /var/www/html




ServerName siva1.example.com
ProxyRequests Off
ProxyPass / http://192.168.1.150/
#Wireless AP
ProxyPassReverse / http://192.168.1.150/

Order Allow,Deny
Allow from all


#
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#






REFERENCES
http://httpd.apache.org/docs/1.3/mod/mod_proxy.html#proxypass

Notifications configured to be sent with SMTP mail in Backup Exec are not being sent.

— SkyHi @ Tuesday, July 13, 2010
Does your SMTP server require authentication ???

Please refer to
the following document
SMTP
notification configured to be sent from Backup Exec for Windows Servers,
requiring authentication to the SMTP server, fails to be sent
http://support.veritas.com/docs/290886


Notifications
configured to be sent with SMTP mail in Backup Exec 9.x and 10.x are not
being sent.
http://support.veritas.com/docs/282931

SMTP
(Simple Mail Transfer Protocol) notification is configured and enabled
within Backup Exec but no notification is received after the job runs.
http://support.veritas.com/docs/264683


How
to configure backup jobs to send notification using Backup Exec 9.x and
10.x (includes SMTP configuration)
http://support.veritas.com/docs/253178

REFERENCES
http://www.experts-exchange.com/Storage/Backup_Restore/Backup_Exec/Q_23300965.html


Details:




The procedure in this article should be followed if

notifications are not being received, including situations where:



  • A

    recipient is configured to be notified of a job, selection list or alert

    category.
  • Test

    notification emails work every time.
  • A

    recipient use to receive notifications but does not receive them

    anymore.


To allow notifications to start

being sent again perform the following:



1.  Confirm

the SMTP Mail settings are configured correctly.





Click on

Tools --> E-mail and Pager Notification. (Figure 1)





Figure 1



 



 Ensure the settings are configured correctly for the

environment.



2.  Go

to Tools --> Recipients... and select a recipient that is not receiving

notifications then click Properties. (Figure 2)





Figure 2


 





3.  In

the SMTP Mail tab, uncheck the Enable check box in the "Limit the number of

notifications sent." (Figure 3)





Figure

3



 







4.  Click

OK





5.  Click

Cancel





Note: Read below for a detailed explanation of the how the

notification facilities in Backup Exec work.


Configuring

Notifications




Backup Exec allows the backup

operator to set up notifications on three levels within Backup Exec.


  • Alert

    Category Level
  • Policy

    / Backup Job / Restore Job / Level
  • Selection

    list level






Alert Category Level



Figure 4


 





Figure 5


 



Figure 4 displays how to navigate to the Alert Categories window in

Backup Exec and the notification related areas are highlighted with red boxes in

Figure 5.

Backup Exec allows notifications for various alert categories

or states that may occur during the operation of the software. Simply select the

alert category from the Alert Categories list box (Figure 5), select the "Send

notifications to selected recipients" check box and then nominate the relevant

recipients. For a job log to be sent with the notification, select the "Include

job log with a notification to an e-mail or printer recipient" check

box.

When notifications are set at this level, Backup Exec will notify

the selected recipients whenever this alert category or state is entered. This

means any job or component of Backup Exec that uses the alert

selected will send notifications to the recipients that are configured for the

alert category.

Policy / Backup Job / Restore Job and Selection List

Levels




Figure 6


 

The

red boxes in Figure 6 again highlight the areas of interest in the Backup Job

properties window. Note: The areas highlighted will be

available depending on which area of the program is open.  For example, the

selection list creation / modification window will only have the Selection List

Notification section, backup job properties and restore job properties will have

all of these notification sections.


If both "Selection List

Notification" under "Source" and "Notification" under Settings is configured,

then Backup Exec will send out two sets of notifications to the

recipients that have been configured. One set of notifications will be sent out

related to the selection list and another will be sent out for the actual job

completion. If include job logs has been chosen, then it will also be attached

to each set of notifications if e-mail or printer notifications are

configured.

Summary

There are multiple levels of

notifications in Backup Exec. There is a general "Alert" level of notifications,

a "Job" level of notifications and a "Selection list" level of notifications.



All of these levels are controlled by the configuration settings that

are set for each recipient in the Tools--> Recipients --> SMTP Mail tab.

In this tab, the "Limit the number of notifications sent" area is very

important. The settings here dictate whether or not a recipient receives a

notification or not.

When enabled, the default value is "Notify me a

maximum of 5 times within 5 minutes
." The "Reset the notification limits

after 15 minutes
" check box is not selected by default.

If the

"Reset the notification limits after 15 minutes" check box is left

unchecked, after the notifications number sent reaches the maximum configured

for that recipient they will not receive any further notifications. If this

check box is checked, after the 15 minutes (if using the default value) elapses

this recipient is able to receive up to his maximum limit of notifications until

the reset notification limit time interval elapses and the notification limit

counters for this recipient are again met.


If recipients are

receiving more than one notification for a single event it is because Backup

Exec was configured to send a combination of alert level notifications, job

level notifications and possibly selection list notifications.

REFERENCES
http://seer.entsupport.symantec.com/docs/282931.htm

Kernel sysctl configuration file for Linux

— SkyHi @ Tuesday, July 13, 2010
sysctl.conf
# Kernel sysctl configuration file for Linux
#
# Version 1.9 - 2011-03-23
# Michiel Klaver - IT Professional
# http://klaver.it/linux/ for the latest version - http://klaver.it/bsd/ for a BSD variant
#
# This file should be saved as /etc/sysctl.conf and can be activated using the command:
# sysctl -e -p /etc/sysctl.conf
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and sysctl.conf(5) for more details.
#
# Tested with: Debian 4 etchnhalf kernel version 2.6.24 default stock out-of-the-box
#              Debian 5 kernel version 2.6.26 default stock out-of-the-box
#              CentOS 5.4 kernel 2.6.18 default stock out-of-the-box

#
# Intended use for dedicated server systems at high-speed networks with loads of RAM and bandwidth available
# Optimised and tuned for high-performance web/ftp/mail/dns servers with high connection-rates
# DO NOT USE at busy networks or xDSL/Cable connections where packetloss can be expected
# ----------

# Credits:
# http://www.enigma.id.au/linux_tuning.txt
# http://www.securityfocus.com/infocus/1729
# http://fasterdata.es.net/TCP-tuning/linux.html
# http://fedorahosted.org/ktune/browser/sysctl.ktune
# http://www.cymru.com/Documents/ip-stack-tuning.html
# http://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt
# http://www.frozentux.net/ipsysctl-tutorial/chunkyhtml/index.html
# http://knol.google.com/k/linux-performance-tuning-and-measurement
# http://www.cyberciti.biz/faq/linux-kernel-tuning-virtual-memory-subsystem/
# http://www.redbooks.ibm.com/abstracts/REDP4285.html
# http://www.speedguide.net/read_articles.php?id=121
# http://lartc.org/howto/lartc.kernel.obscure.html
# http://en.wikipedia.org/wiki/Sysctl



###
### GENERAL SYSTEM SECURITY OPTIONS ###
###

# Auto-reboot linux 30 seconds after a kernel panic
kernel.panic = 30
kernel.panic_on_oops = 30

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1

#Allow for more PIDs
kernel.pid_max = 65536

# The contents of /proc/<pid>/maps and smaps files are only visible to
# readers that are allowed to ptrace() the process
kernel.maps_protect = 1

#Enable ExecShield protection
kernel.exec-shield = 1
kernel.randomize_va_space = 1

# Controls the maximum size of a message, in bytes
kernel.msgmnb = 65536

# Controls the default maxmimum size of a mesage queue
kernel.msgmax = 65536



###
### IMPROVE SYSTEM MEMORY MANAGEMENT ###
###

# Increase size of file handles and inode cache
fs.file-max = 209708

# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2

# specifies the minimum virtual address that a process is allowed to mmap
vm.mmap_min_addr = 4096

# No overcommitment of available memory
vm.overcommit_ratio = 0
vm.overcommit_memory = 0

# Set maximum amount of memory allocated to shm to 256MB
kernel.shmmax = 268435456
kernel.shmall = 268435456

# Keep at least 64MB of free RAM space available
vm.min_free_kbytes = 65536



###
### GENERAL NETWORK SECURITY OPTIONS ###
###

#Prevent SYN attack, enable SYNcookies (they will kick-in when the max_syn_backlog reached)
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_max_syn_backlog = 4096

# Disables packet forwarding
net.ipv4.ip_forward = 0
net.ipv4.conf.all.forwarding = 0
net.ipv4.conf.default.forwarding = 0
net.ipv6.conf.all.forwarding = 0
net.ipv6.conf.default.forwarding = 0

# Disables IP source routing
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv6.conf.all.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0

# Enable IP spoofing protection, turn on source route verification
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1

# Disable ICMP Redirect Acceptance
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0

# Disable Log Spoofed Packets, Source Routed Packets, Redirect Packets
net.ipv4.conf.all.log_martians = 0
net.ipv4.conf.default.log_martians = 0

# Decrease the time default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 15

# Decrease the time default value for connections to keep alive
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 15

# Don't relay bootp
net.ipv4.conf.all.bootp_relay = 0

# Don't proxy arp for anyone
net.ipv4.conf.all.proxy_arp = 0

# Turn on SACK
net.ipv4.tcp_dsack = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_fack = 1

# Turn on the tcp_timestamps
net.ipv4.tcp_timestamps = 1

# Don't ignore directed pings
net.ipv4.icmp_echo_ignore_all = 0

# Enable ignoring broadcasts request
net.ipv4.icmp_echo_ignore_broadcasts = 1

# Enable bad error message Protection
net.ipv4.icmp_ignore_bogus_error_responses = 1

# Allowed local port range
net.ipv4.ip_local_port_range = 16384 65536

# Enable a fix for RFC1337 - time-wait assassination hazards in TCP
net.ipv4.tcp_rfc1337 = 1



###
### TUNING NETWORK PERFORMANCE ###
###

# Do a 'modprobe tcp_cubic' first
net.ipv4.tcp_congestion_control = cubic

# Turn on the tcp_window_scaling
net.ipv4.tcp_window_scaling = 1

# Increase the maximum total buffer-space allocatable
# This is measured in units of pages (4096 bytes)
net.ipv4.tcp_mem = 65536 131072 262144
net.ipv4.udp_mem = 65536 131072 262144

# Increase the read-buffer space allocatable
net.ipv4.tcp_rmem = 8192 87380 16777216
net.ipv4.udp_rmem_min = 16384
net.core.rmem_default = 131072
net.core.rmem_max = 16777216

# Increase the write-buffer-space allocatable
net.ipv4.tcp_wmem = 8192 65536 16777216
net.ipv4.udp_wmem_min = 16384
net.core.wmem_default = 131072
net.core.wmem_max = 16777216

# Increase number of incoming connections
net.core.somaxconn = 32768

# Increase number of incoming connections backlog
net.core.netdev_max_backlog = 4096
net.core.dev_weight = 64

# Increase the maximum amount of option memory buffers
net.core.optmem_max = 65536

# Increase the maximum number of skb-heads to be cached
#net.core.hot_list_length = 1024

# Increase the tcp-time-wait buckets pool size to prevent simple DOS attacks
net.ipv4.tcp_max_tw_buckets = 1440000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1

# Limit number of orphans, each orphan can eat up to 16M (max wmem) of unswappable memory
net.ipv4.tcp_max_orphans = 16384
net.ipv4.tcp_orphan_retries = 0

# Increase the maximum memory used to reassemble IP fragments
net.ipv4.ipfrag_high_thresh = 512000
net.ipv4.ipfrag_low_thresh = 446464

# don't cache ssthresh from previous connection
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.tcp_moderate_rcvbuf = 1

# Increase RPC slots
sunrpc.tcp_slot_table_entries = 32
sunrpc.udp_slot_table_entries = 32

# Increase size of RPC datagram queue length
net.unix.max_dgram_qlen = 50

# Don't allow the arp table to become bigger than this
net.ipv4.neigh.default.gc_thresh3 = 2048

# Tell the gc when to become aggressive with arp table cleaning.
# Adjust this based on size of the LAN. 1024 is suitable for most /24 networks
net.ipv4.neigh.default.gc_thresh2 = 1024

# Adjust where the gc will leave arp table alone - set to 32.
net.ipv4.neigh.default.gc_thresh1 = 32

# Adjust to arp table gc to clean-up more often
net.ipv4.neigh.default.gc_interval = 30

# Increase TCP queue length
net.ipv4.neigh.default.proxy_qlen = 96
net.ipv4.neigh.default.unres_qlen = 6

# Enable Explicit Congestion Notification (RFC 3168), disable it if it doesn't work for you
net.ipv4.tcp_ecn = 1
net.ipv4.tcp_ecn = 2
net.ipv4.tcp_reordering = 3

# How many times to retry killing an alive TCP connection
net.ipv4.tcp_retries2 = 15
net.ipv4.tcp_retries1 = 3

# This will enusre that immediatly subsequent connections use the new values
net.ipv4.route.flush = 1
net.ipv6.route.flush = 1



###
### Comments/suggestions/additions are welcome!
###


rc.iptables
#!/bin/bash
#### BEGIN INIT INFO
# Provides:          iptables
# Required-Start:    $network
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: iptables firewall script
# Description:       iptables firewall script
### END INIT INFO

###
### FireWall script - v1.1 Michiel Klaver 2008-10-29
###



set -e

. /lib/init/vars.sh
. /lib/lsb/init-functions

# iptables Location - adjust if needed
IPT="/sbin/iptables"

# Internet Interface
INET_IFACE="eth0"

# Localhost Interface
LO_IFACE="lo"
LO_IP="127.0.0.1"



# we do not use forwarding / NAT
echo 0 > /proc/sys/net/ipv4/ip_forward

# remove any existing ipchains
([ -f /var/lock/subsys/ipchains ] && /etc/init.d/ipchains stop) >/dev/null 2>&1 || true
(rmmod ipchains) >/dev/null 2>&1 || true

# insert iptable modules
/sbin/modprobe ip_tables
/sbin/modprobe ipt_state
/sbin/modprobe iptable_filter
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp



# clear all previous iptable rules
$IPT -F
$IPT -X
$IPT -Z

# do not use forwarding / NAT
$IPT -t nat -F
$IPT -t nat -X
$IPT -t nat -Z

# do not alter packets
$IPT -t mangle -F
$IPT -t mangle -X
$IPT -t mangle -Z



case "$1" in
    stop|open|clear|reset)
 # set default policy for all traffic to ACCEPT
 $IPT -P INPUT ACCEPT
 $IPT -P OUTPUT ACCEPT
 $IPT -P FORWARD ACCEPT
 
 $IPT -A INPUT -j ACCEPT
 $IPT -A OUTPUT -j ACCEPT
 $IPT -A FORWARD -j ACCEPT
 exit 0
    ;;
esac



# set default policy for all traffic to DROP
$IPT -P INPUT DROP
$IPT -P OUTPUT DROP
$IPT -P FORWARD DROP

# Every new connection attempt should begin with a syn packet.  If it doesn't, it is likely a
# port scan.  This drops packets in state NEW that are not flagged as syn packets.
$IPT -A INPUT -p all -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
$IPT -A INPUT -p all -m state --state INVALID -j DROP

$IPT -A OUTPUT -p all -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPT -A OUTPUT -p tcp ! --syn -m state --state NEW -j DROP
$IPT -A OUTPUT -p all -m state --state INVALID -j DROP



# ICMP packets should fit in a Layer 2 frame, thus they should
# never be fragmented.  Fragmented ICMP packets are a typical sign
# of a denial of service attack.
$IPT -A INPUT --fragment -p ICMP -j DROP

# Block stealth portscans
$IPT -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
$IPT -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
$IPT -A INPUT -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
$IPT -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
$IPT -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
$IPT -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP

# all connections from / to localhost are allowed
$IPT -A INPUT -p all -i $LO_IFACE -j ACCEPT
$IPT -A OUTPUT -p all -o $LO_IFACE -j ACCEPT
$IPT -A OUTPUT -p all -s $LO_IP -j ACCEPT



# HTTP / HTTPS
$IPT -A INPUT -p tcp --dport 80 -j ACCEPT
$IPT -A INPUT -p tcp --dport 443 -j ACCEPT

# FTP
$IPT -A INPUT -p tcp --dport 20 -j ACCEPT
$IPT -A INPUT -p tcp --dport 21 -j ACCEPT

# SSH
$IPT -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --set
$IPT -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 60 --hitcount 4 -j REJECT --reject-with tcp-reset
$IPT -A INPUT -p tcp --dport 22 -j ACCEPT

# SMTP / SSMTP
$IPT -A INPUT -p tcp --dport 25 -j ACCEPT
$IPT -A INPUT -p tcp --dport 465 -j ACCEPT
$IPT -A INPUT -p tcp --dport 587 -j ACCEPT

# POP3PASS
$IPT -A INPUT -p tcp --dport 106 -j ACCEPT

# POP3 / POP3S
$IPT -A INPUT -p tcp --dport 110 -j ACCEPT
$IPT -A INPUT -p tcp --dport 995 -j ACCEPT

# IMAP / IMAPS
$IPT -A INPUT -p tcp --dport 143 -j ACCEPT
$IPT -A INPUT -p tcp --dport 993 -j ACCEPT

# MySQL
$IPT -A INPUT -p tcp --dport 3306 -j ACCEPT

# PostgreSQL
$IPT -A INPUT -p tcp --dport 5432 -j ACCEPT

# DNS
$IPT -A INPUT -p udp --dport 53 -j ACCEPT
$IPT -A INPUT -p tcp --dport 53 -j ACCEPT

# Admin Panels (Plesk / DirectAdmin)
$IPT -A INPUT -p tcp --dport 8443 -j ACCEPT
$IPT -A INPUT -p tcp --dport 2222 -j ACCEPT

# ICMP
$IPT -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
$IPT -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
$IPT -A INPUT -p icmp --icmp-type destination-unreachable -j ACCEPT
$IPT -A INPUT -p icmp --icmp-type fragmentation-needed -j ACCEPT
$IPT -A INPUT -p icmp --icmp-type source-quench -j ACCEPT
$IPT -A INPUT -p icmp --icmp-type time-exceeded -j ACCEPT
$IPT -A INPUT -p icmp --icmp-type parameter-problem -j ACCEPT



# UDP part of tracerouting
$IPT -A INPUT  -p udp --sport 32769:65535 --dport 33434:33523 -j ACCEPT
$IPT -A OUTPUT -p udp --sport 32769:65535 --dport 33434:33523 -j ACCEPT

# SSH
$IPT -A OUTPUT -p tcp --dport 22 -j ACCEPT

# SMTP
$IPT -A OUTPUT -p tcp --dport 25 -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 465 -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 587 -j ACCEPT

# POP3/IMAP
$IPT -A OUTPUT -p tcp --dport 110 -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 143 -j ACCEPT

# HTTP/HTTPS
$IPT -A OUTPUT -p tcp --dport 80 -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 443 -j ACCEPT

# DNS
$IPT -A OUTPUT -p udp --dport 53 -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 53 -j ACCEPT

# SNMP
$IPT -A OUTPUT -p udp --dport 161 -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 161 -j ACCEPT
$IPT -A OUTPUT -p udp --dport 162 -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 162 -j ACCEPT

# NTP (date/time)
$IPT -A OUTPUT -p tcp --dport 37 -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 123 -j ACCEPT
$IPT -A OUTPUT -p udp --dport 123 -j ACCEPT

# WhoIs clientside
$IPT -A OUTPUT -p tcp --dport 43 -j ACCEPT

# Razor2/Pyzor/DCC (spamchecks)
$IPT -A OUTPUT -p udp --dport 24441 -j ACCEPT
$IPT -A OUTPUT -p udp --dport 6277 -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 2703 -j ACCEPT
$IPT -A OUTPUT -p tcp --dport 7 -j ACCEPT

# MySQL
$IPT -A OUTPUT -p tcp --dport 3306 -j ACCEPT

# PostgreSQL
$IPT -A OUTPUT -p tcp --dport 5432 -j ACCEPT

# ICMP
$IPT -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
$IPT -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
$IPT -A OUTPUT -p icmp --icmp-type destination-unreachable -j ACCEPT
$IPT -A OUTPUT -p icmp --icmp-type fragmentation-needed -j ACCEPT
$IPT -A OUTPUT -p icmp --icmp-type source-quench -j ACCEPT
$IPT -A OUTPUT -p icmp --icmp-type time-exceeded -j ACCEPT
$IPT -A OUTPUT -p icmp --icmp-type parameter-problem -j ACCEPT



# DROP any other protocol other than stated above
$IPT -A INPUT -j DROP
$IPT -A OUTPUT -j DROP
$IPT -A FORWARD -j DROP



$IPT -L -n


REFERENCES
http://klaver.it/linux/sysctl.conf

Centralized Backup Server With Amanda On CentOS

— SkyHi @ Tuesday, July 13, 2010

This document describes how to set up a centralized network backup with Amanda. We will use virtual tape to store the backup.


In my environment, I have 2 Linux servers that I want to backup.


192.168.20.200 (Alpha) : /home/kulathep


192.168.20.201 (Beta) : /data and /var


I am going to build a new server with Amanda as a centralized backup server.


192.168.20.202 (Gamma)


Setup Server (Gamma)


1. Install Amanda with yum:


yum -y install amanda*


2. Edit Amanda conf in xinetd.d:


vi /etc/xinetd.d/amanda

vi /etc/xinetd.d/amandaidx

vi /etc/xinetd.d/amidxtape


Change Disable = yes to Disable = no.


3. Copy Amanda conf files:


cp -r /etc/amanda/DailySet1 /etc/amanda/intra


4. Edit amanda.conf:


vi /etc/amanda/intra/amanda.conf


org “Configuration name”

mailto “email”

netusage 600 Kbps


dumpcycle 2 weeks

runspercycle 10

tapecycle 15 tapes


#tpchanger “chg-manual”

tpchanger “chg-disk”


changerfile “/etc/amanda/intra/changer”


#tapedev “null:”

tapedev “file:/backup/intra/slots”


#tapetype HP-DAT

#labelstr “^DailySet1-[0-9][0-9]*$”


tapetype HARDDISK

define tapetype HARDDISK {

comment “Backup to Virtual Tape”

length 3072 mbytes # each tape is 3 Gigs

}


# amrecover_changer “null:”

amrecover_changer “changer”


#infofile “/etc/amanda/DailySet1/curinfo” # database DIRECTORY

#logdir “/etc/amanda/ DailySet1″ # log directory

#indexdir “/etc/amanda/ DailySet1/index” # index directory

infofile “/var/log/amanda/intra/curinfo” # database DIRECTORY

logdir “/var/log/amanda/intra” # log directory

indexdir “/var/log/amanda/intra/index” # index directory


With this configuration, Amanda will do a full backup every 2 weeks, and an incremental backup every week day. The backup will be stored and rotated on 15 virtual tapes.


5. Edit disklist (tell Amanda which servers, directory to backup, what dumptype to use).


vi /etc/amanda/intra/disklist


Remove every lines including “localhost /etc comp-root-tar” at the end of the file. And add:


alpha /home/kulathep comp-user-tar

beta /data comp-user-tar

beta /var comp-user-tar


Note: See amanda.conf for the dumptype.


6. Edit hosts file:


vi /etc/hosts


Add:


192.168.20.200 alpha

192.168.20.201 beta


7. Create backup directory (we will store the backup here):


mkdir -p -m 770 /backup/intra/slots

chown -R amanda:disk /backup


8. Create tape list:


touch /etc/amanda/intra/tapelist

chown –R amanda:disk /etc/amanda/intra


9. Create slots (virtual tapes):


su - amanda

cd /backup/intra/slots

for ((i=1; $i<=15; i++)); do mkdir slot$i; done

ln -s slot1 data


10. Test virtual tapes:


/usr/sbin/ammt -f file:/backup/intra/slots status


11. Label the virtual tapes:


for ((i=1; $i<=15; i++)); do /usr/sbin/amlabel intra intra-$i slot $i; done


12. Reset the tape:


/usr/sbin/amtape intra reset


13. Edit .amandahosts to allow communications from clients:


vi /var/lib/amanda/.amandahosts


alpha amanda

beta amanda

gamma amanda


14. Start xinetd service:


su –

service xinetd start


15. Check amanda process:


lsof | grep amanda


Set Up Client


1. Install amanda client with yum:


yum -y install amanda-client


2. Edit file .amandahosts to allow communications from server:


vi /var/lib/amanda/.amandahosts


gamma amanda


3. Edit xinetd.d:


vi /etc/xinetd.d/amanda


Disable = no


4. Start xinetd:


service xinetd start


5. Check Amanda service:


lsof | grep amanda


Backup Data


1. Check tapes and clients on server:


su - amanda

/usr/sbin/amcheck intra


2. Dump manually:


/usr/sbin/amdump intra


3. Add amdump to cron:


crontab –e


0 16 * * 1-5 /usr/sbin/amcheck -m intra

45 0 * * 2-6 /usr/sbin/amdump intra


The first line checks the tape/clients and sends an email if it found something wrong (no email if everything is okay) at 4pm.


The second line dumps at 12.45am on weekdays.


Restore Data


1. Prepare tapes:


cd /tmp

/usr/sbin/amtape intra slot 1 # select slot1 (tape1)

/usr/sbin/ammt -t file:/backup/intra/slots rewind # rewind


2.1. Restore everything from every server:


/usr/sbin/amrestore file:/backup/intra/slots


2.2. Restore only a server and a directory:


/usr/sbin/amrestore file:/backup/intra/slots beta /var


3. Extract:


tar xvf <Restored files>



REFERENCES
http://redhatvn.net/centralized-backup-server-with-amanda-on-centos


Installing LES (Linux Environment Security) on CentOS

— SkyHi @ Tuesday, July 13, 2010
:: Whati is
Please take a look at this.

:: Installing LES
[root@centoz ~]# mkdir download
[root@centoz ~]# cd download/
[root@centoz download]# wget http://www.r-fx.ca/downloads/les-current.tar.gz
[root@centoz download]# tar -xzf les-current.tar.gz
[root@centoz download]# cd les-0.2/
[root@centoz les-0.2]# ./install.sh
.: LES installed
Install path: /usr/local/les
Config path: /usr/local/les/conf.les
Executable path: /usr/local/sbin/les

:: Running LES
[root@centoz les-0.2]# /usr/local/sbin/les -ea
You can try other options :
-da | --disable-all       Disable all options
-ea | --enable-all Enable all options
-sb | --secure-bin Set root only execution of critical binaries
-sp | --secure-path Set root only traversal of critical paths
-sr | --secure-rpmpkg Set immutable on core rpm package binaries
-so | --secure-prof Set immutable on interactive login profiles
-sd | --secure-devel Set access to devel utils for group deva & root


REFERENCES
http://www.blackonsole.org/2009/07/installing-les-linux-environment.html

How to disable wget

— SkyHi @ Tuesday, July 13, 2010
wget is one of the largest threats for your server security. A single abuser that gains access to wget can download and run any script that he wants, totally compromising your server.



It is highly recommended that you allow only root to use wget and you restrict all other users from it.



1. Login to your server as root

2. Run the fallowing command



chmod 0700 /usr/bin/wget



Please note that disabling wget might cause some scripts to stop working. A known problem is that Fantastico will stop updating after this. The solution is pretty easy…

Before you disable wget make sure that you do a copy of it with the initial permissions. You can use any name that you want, the following is just an example:



cp /usr/bin/wget /usr/bin/wget_secret





In the Fantastico configuration input the location to wget as:



/usr/bin/wget_secret



If for some reason you you want to revert the change you simply have to do:



chmod 0711 /usr/bin/wget

=================================================================

I make it a habbit on my systems to chmod 700 some of the keyfiles
like wget, netstat. Also a good idea to set your /tmp to noexec.



dropby23




there are alot of ways to get a file in the server i am ussualy using
this one

chmod 750 /usr/bin/rcp

chmod 750 /usr/bin/wget

chmod 750 /usr/bin/lynx

chmod 750 /usr/bin/links

chmod 750 /usr/bin/scp

chmod 750 /usr/bin/nc

chmod 750 /usr/bin/elinks

chmod 750 /usr/bin/curl

rm -rf /etc/httpd/proxy/

chmod 000 /var/mail/vbox

rm -rf /usr/local/apache/proxy

chmod 700 /usr/bin/lwp-*

chmod 750 /usr/bin/GET

chmod 750 /usr/bin/curl



HostGeekZ




Install LES, which will chmod/chattr most of these binarys for you.

REFERENCES
http://www.cyberls.com/forum/showthread.php?tid=440
http://forums.theplanet.com/lofiversion/index.php/t81289.html


Outlook 2003 freezing

— SkyHi @ Tuesday, July 13, 2010
click on start => run => type outlook /safe and press Ok.

check outlook in this mode.

click on tools => options => other => advanced options => click on com addins and list the addins you have

REFERENCES
http://www.techsupportforum.com/microsoft-support/microsoft-office-support/287117-outlook-2003-freezing.html