Wednesday, June 28, 2006

Linux: Setting the Hostname

This is useful when your linux box is used for sending emails. If hostname is incorrect, it will be detected by http://cbl.abuseat.org and will be blocked from sending emails.

Example of a computer's hostname: mybox.mydomain.com

Replace example hostname to your computer's hostname.

In Linux, to check the hostname if it is similar to this example:

[root@mybox ~]# uname -n
mybox.mydomain.com
[root@mybox ~]# hostname -s
mybox
[root@mybox ~]# hostname -d
mydomain.com
[root@mybox ~]# hostname -f
mybox.mydomain.com
[root@mybox ~]# hostname
mybox.mydomain.com

If it returns localhost.localdomain then it's wrong. If not then your linux box is ok. (Very big hint for me was that before, the command prompt was [root@localhost ~]#)

For a static IP Address, /etc/hosts is configured as follows:
127.0.0.1 localhost.localdomain localhost
192.168.0.xxx mybox.mydomain.com mybox


Change 192.168.0.xxx to your static IP Address.

Set hostname:
[root@localhost ~]# hostname mybox.mydomain.com

Check /etc/sysconfig/network file. Must have be like this:
NETWORKING=yes
HOSTNAME="mybox.mydomain.com"

For further reference:
http://www.cpqlinux.com/hostname.html

* Using Fedora Core 3

Tuesday, June 27, 2006

Forms: Input validation

Input text and text areas

  1. For required fields, is string empty? Remove trailing spaces.
  2. Scope of string. (numeric, letters only ??)
  3. Minimum and maximum length of string.

Input file

  1. Is string empty?
  2. Does file exist?
  3. File must be of valid type.
  4. Limit the type of files that can be uploaded.

Check box

  1. Grouped check boxes must be same name.
  2. If multiple check boxes, can check multiple boxes.
  3. If field is required, at least one check box checked or depending on specs.

Radio button

  1. Grouped radio buttons must be same name.
  2. If multiple radio buttons, can only check one radio button per group.
  3. If field is required, must have ticked a radio button.

Selections (Dropdown)

  1. Do not put default empty value if required field.
  2. Check other dropdown in same group if not selected. (like in date and time)
  3. For group selections, check format or combination.

Input submit (Submit button)

  1. Do not submit if there are invalid input in form.

Input reset (Reset button)

  1. All default values must be returned as if the form was loaded again from the start.

Thursday, June 22, 2006

Linux: Accept Local SSH only

Linux Firewall must be running.

In /etc/sysconfig/iptables

find the following line

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

and change to

-A RH-Firewall-1-INPUT -s xxx.xxx.xxx.0/24 -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

replace xxx.xxx.xxx.0 with local IP range.

restart firewall

[root@localhost ~]# service iptables restart

(Thanks to Sasi)