Cannot install binary packages using pkg_addCannot install binary packages using pkg_add

Failure to install binary packages in older FreeBSD versions using “pkg_add -r”.


Solution:

Add these lines to /etc/csh.cshrc (/etc/profile if you are using bash or sh):

[FreeBSD 4.x]
setenv PACKAGESITE ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-4-stable/Latest/
setenv PACKAGELIST

[FreeBSD 5.x]
setenv PACKAGESITE ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-5-stable/Latest/
setenv PACKAGELIST

How To Find What Version of PEAR Is Installed in your Linux Apache Server

if you want to know what version of PEAR you have, or simply just want to know if you have PEAR installed, simply run the following command in your linux box shell prompt:

pear list

Once you execute the command above, you should see something like this:

Installed packages
===================
Package
Version
State
Archive_Tar
1.1
stable
Console_Getopt
1.2
stable
DB
1.7.6
stable
HTML_Template_IT
1.1
stable
HTTP
1.3.6
stable
Mail
1.1.8
stable
Net_SMTP
1.2.7
stable
Net_Socket
1.0.6
stable
Net_UserAgent_Detect
2.0.1
stable
PEAR
1.3.6
stable
XML_Parser
1.2.6
stable
XML_RPC
1.4.1
stable

If you don’t see anything like the above, then you dont have PEAR installed. However, Good new I have, you can download free at http://pear.php.net

How to track which site is using the apache processes.

For apache 1.3, edit your /etc/httpd/conf/httpd.conf and add

ExtendedStatus On <Location /httpd-status> SetHandler server-status Order deny,allow Deny from all Allow from 127.0.0.1 </Location>

 

 

 

just after the code that says “ServerSignature On”. Save, exit, then restart apache. You can access the stats page by going to http://1.2.3.4/httpd-status where 1.2.3.4 is your server’s IP.

If you’re running apache 2.x , then it’s already in the file:
/etc/httpd/conf/extra/httpd.conf
Change the “Allow from” lines to include your IP.

Under cPanel servers the code is already present but you need to uncomment it or just add the code :

<Location /whm-server-status> 
SetHandler server-status 
Order deny,allow 
Deny from all 
Allow from 127.0.0.1
</Location>

Need to change IP address in FreeBSD

Issue: A change of IP address is needed in FreeBSD.

Solution: If you do not have the root password boot into Single User mode [option 4]. Procced to step 1.

If you have the root password procced to step 2.

1. mount -o (if you get a read-only error, you will have to run fschk -y)

2. vi /etc/rc.conf (If vi is unavailable use ee)

at this point simply edit the IP Address lines that will need to be corrected.

How to bind IPs on a Windows Server

1. Start -> Settings -> Control Panel -> Network Connections
2. Right click and go to properties of the enabled/active NIC
3. Highlight on TCP/IP and click on properties
4. Select ” Use the following IP address ”
5. Enter your IP information for the server.
6. Click on Advanced
7. Click Add on the IP Settings tab.
8. Enter the usable IP range along with the netmask. ( ie 255.255.255.0 )
9. Click OK.

DNS Overview

Most records will be A records. This allows the greatest versatility in pointing your domain names where you want them go. Each record consists of a host name and an IP address.

Host field: The host name for that particular A record. The host name should be what precedes the .domain.com in your FQDN (fully qualified domain name). For instance, on www.domain.com, “www” is the host (without the quotation marks). Whatever is listed here, the lookup will automatically append “.domain.com” to the query. A blank A record ( domain.com rather than host.domain.com) is created by putting a ‘@’ sign in the host name field.

Common “A” records include: www.domain.com, ftp.domain.com, mail.domain.com, webmail.domain.com, mysql.domain.com

Points to field: This is where you list the IP address to which the host name should point.

CNAME section:

CNAME records point to domain names instead of IP addresses. The benefit to using a CNAME record is you can point a host to a particular domain name then only modify the target domain name’s A records to have the change take place on both domains. This is commonly used by those who own several TLD versions (.com, .net, .org, etc.) of the same domain.

For example, you own domain.com and you also own domain.net and you want the records to point to the same IP. You can create CNAME records for the www host of domain.net that point to www.domain.com. Then all you have to do to change the www host of domain.net is modify the A record of www.domain.com to point to its new IP address and www.domain.net is automatically changed:

A common mistake to using this method is that you can accidentally modify the records for several domains when you only intend to change one. I.E. – you have to make a note of which domains point to each other

Host field: The host name for that particular CNAME record. The host name should be what precedes the .domain.com in your FQDN. For instance, on www.domain.com, “www” is the host (without the quotation marks). Whatever is listed here, the lookup will automatically append “.domain.com” to the query. A blank A record ( domain.com rather than host.domain.com) is created by putting a ‘@’ sign in the host name field.

Points to field: The name that the record points to. This must be a domain name, and not an IP address. The domain name must also end with a dot. Otherwise, the domain record will wrap down when queried to the next period in the zone file.

MX section:

The MX section is the area that handles the direction of mail.

Priority field: This allows you to select your preference for an individual MX records. Records are procesed in order starting with the lowest priority and working to higher priorities. What this means is, if you have two mailservers or a mailserver and a mail spooler, set the lower priority to your main mailserver and a higher priorty to your backup mailserver or mail spooler.

Host field: You can specify a mail host name here, but in most cases it is not necessary. What is recommended is to create a blank host (use a ‘@’ for the host name) and point it to your mail server.

Goes to field: The address of the mail server. What is commonly done here is using the mail hostname you created in the A record section to point your mail.

It is highly recommended that you point MX records to a domain name, and that domain name (just like a CNAME record) must end with a dot.

TXT section:

A TXT record generally is a record that you can query which return information about a domain. These can be used for SPF indicators, crafting port an protocol connections, or just returning information about a domain. These are most commonly used with the spf protocol.

Name: The host that the TXT record can be queried by.

Value: What the TXT record will return, placed in quotes.

Crontab basics

cron is a unix, solaris utility that allows tasks to be automatically run in the background at regular intervals by the cron daemon. These tasks are often termed as cron jobs in unix , solaris.
Crontab (CRON TABle) is a file which contains the schedule of cron entries to be run and at specified times.


Crontab syntax


A crontab file has five fields for specifying day , date and time  followed by the command to be run at that interval.

*     *   *   *    *  command to be executed
–     –    –    –    –
|     |     |     |     |
|     |     |     |     +—– day of week (0 – 6) (Sunday=0)
|     |     |     +——- month (1 – 12)
|     |     +——— day of month (1 – 31)
|     +———– hour (0 – 23)
+————- min (0 – 59)

* in the value field above means all legal values as in braces for that column.
The value column can have a * or a list of elements separated by commas. An element is either a number in the ranges shown above or two numbers in the range separated by a hyphen (meaning an inclusive range).

Crontab Example

min      hour      day/month      month      day/week       Execution time
30     0     1     1,6,12     *     — 00:30 Hrs  on 1st of Jan, June & Dec.

0     20     *     10     1-5     –8.00 PM every weekday (Mon-Fri) only in Oct.

0     0     1,10,15     *     *     — midnight on 1st ,10th & 15th of month

5,10     0     10     *     1     — At 12.05,12.10 every Monday & on 10th of every month


By default cron jobs sends a email to the user account executing the cronjob. If this is not needed put the following command At the end of the cron job line .

>/dev/null 2>&1


To collect the cron execution execution log in a file :

30 18  *    *   *    rm /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log

How to block ip addresses with iptables

I have an ip address attacking my server or taking up all my httpd connections so none of my sites work.

In order to correct this you will want to use the netstat -n command to see the ip addresses connected to your server. Once you have the ip address you want to block you can use the following command to block them from accessing your server using iptables

iptables -I INPUT 1 -s IP.ADD.RES.SS -j DROP

-I INPUT 1 means to insert the rule at the top of the INPUT table (which means it will get looked at first)

-s IP.ADD.RES.SS is the source address of the packets we want to deal with

-j DROP means dump the packets into the void, and forget they ever happened.