IPTABLES BASICS

0 comments

IPtables is vast topic which can not be dealt in one post I will be posting this IPtables in different posts but will link all of them

IPtables basics

Iptables is a securit module in Linux kernel, this Iptables can be used a firewall(filter table),Internet sharing(NAT table),For altering Type Of Service(mangle table) and for non tracking purpose(Raw table)

Firewall definition:

A firewall is a security system consisting of a combination of hardware and software that limits the exposure of a computer or computer network to attack from crackers; commonly used on local area networks that are connected to the internet. This is acheived by Filter table

Internetsharing definition:

An Internet standard that enables a LAN to use one set of IP addresses for internal traffic and a second set of addresses for external traffic. A NAT box located where the LAN meets the Internet makes all necessary IP address translations.

Mangling definition:

 Mangling is defined as changing the Type of service value in IP header packet to get the desired values such as decreasing latency(for example telnet,ssh should required less latency) etc. This table is used for imporving some services performance

Non tracking packets definition:

Most of the system/network activitis are logged in some logs, if we want our packets to be not monitored we can use this table, This raw table(which is introduced in 2.6 version linux kernel for some special feature) will set value on each packet not to track where this packet is coming and going.


IPtables is nothing but a set of tables

A table is set of chains and target values.
A chain is nothing but a rule on a packet wether to forword or drop or Reject etc
A rule is nothing but setting a criteria for packet.

Iptables will work on targeting IP packets and chains
These targets may be

  1. ACCEPT
  2. DROP
  3. REJECT
  4. SNAT
  5. DNAT
  6. NOTRACK
  7. BALANCE
  8. CLASSIFY
  9. CLUSTERIP
  10. CONNMARK
  11. DSCP
  12. ECN
  13. LOG
  14. MARK
  15. MASQUERADE
  16. MIRROR
  17. NETMAP
  18. REDIRECT
  19. ROUTE
  20. SET
  21. TCPMSS
  22. TOS
  23. TRACE
  24. TTL
  25. ULOG

these chains may be
  1. INPUT (for packets destined to local sockets),
  2. FORWARD (for packets being routed through the box),
  3. OUTPUT (for locally-generated packets)
  4. PREROUTING (for altering packets as soon as they come in),
  5. POSTROUTING (for altering packets as they are about to go out).
in next post I will be giving some explination to this targets and chains with some practical exampls, thanks for reading the blog and commenting.

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Crontab configuration in Linux

    0 comments

    CRONTAB

    Crontab is the default scheduling Application/program in most of the Linux/Nix boxes.
    Crontab is define as scheduling of programs/scripts/applicaions with out administrator interventions
    Crontab = (Cron)oligical+(tab)le nothing but time table for executing some scripts at that point of time

    So where we requre crontab?
    where there is no need for admin intervetions such as taking dialy backups sending mails to perticular users monitoring network.

    So coming to scheduling task crontab uses clock daemon (/usr/sbin/cron or perhaps /usr/sbin/crond) that executes commands at specific times. and corn tables for each user is located in /var/spool/cron/ with their names
    suppose you want to see cron table for root(cat /var/spool/cron/root)

    Crontab file content

    The content of the file can be devide in to 6 feilds(first 5 for specifing time and last one for executing scripts/app etc)
    The first five fields are separated by either a space or a tab and represent the following units, respectively:

    * minutes (0-59)
    * hour (0-23)
    * day of the month (1-31)
    * month of the year (1-12)
    * day of the week (0-6, 0=Sunday)


    Configuration of crontab for user

    Step1:Creating crontab for a user

    #crontab -e -u username
    -e is for specifing editing and -u for specifing username when you are scheduling crontabs for other users
    if users want to schedule their own he can just give (crontab -e)
    Example:

    I will take one example here to explain crontab,suppose I want to execute one script located in /var/test/script.sh and save the output to /temp/script.out should be executed every 10th of each month at 9:43pm

    #crontab -e -u surya

    so here it will open a temporary in /tmp folder

    43 21 10 * * /var/test/script.sh > /temp/script.out

    here * in month field and week field indicates any month and any week execute this script

    after entering the values save and exit the file, A file will be created in as /var/spool/cron/surya with the above content

    Step2:seeing crontab for a perticular user

    #crontab -l -u username

    Example

    #crontab -l -u surya

    If you are a user and want to see your crontab you can just give (crontab -l)

    Step3:Removing crontab for perticular user

    This can be acheived in two ways
    1)removing all the crontab entries for a perticual user

    #crontab -r -l username

    Example

    #crontab -r -l surya

    2)removing one task for perticual user,for doing this we have to edit the crontab

    #crontab -e -l username

    Please see here some of the crontab issues

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Getting mulitple files from ftp server with out any prompt

    0 comments

    How to get lot of multiple file from server I am using
    FTP command(mget ...), but each file asked "yes/no", every file should be put 'yes'
    then 'Enter'?

    we can resolve this issue in two ways


    1)when you are accessing FTP server use -i option which is nothing but interactive way to get files from FTP server, actually this -i option will disable iteractive download of files from server.

    Syntax:ftp -i server-ip/servername
    #ftp -i 222.1.89.1

    2)This is used when you are middle of the transaction you can use prompt command in ftp mode to get multiple files with out any prompt, here is the example and this is for that session

    ftp> ls
    200 PORT command successful. Consider using PASV.
    150 Here comes the directory listing.
    -rw-r--r-- 1 1005 0 47 Apr 11 19:37 file1.txt
    -rw-r--r-- 1 1005 0 47 Apr 11 19:37 file2.txt
    -rw-r--r-- 1 1005 0 47 Apr 11 19:37 file3.txt
    -rw-r--r-- 1 1005 0 47 Apr 11 19:37 file4.txt
    226 Directory send OK.

    ftp> prompt
    Interactive mode off.

    ftp> mget *
    local: file1.txt remote: file1.txt
    200 PORT command successful. Consider using PASV.
    150 Opening BINARY mode data connection for file1.txt (47 bytes).
    226 File send OK.
    47 bytes received in 0.00 secs (72.1 kB/s)
    local: file2.txt remote: file2.txt
    200 PORT command successful. Consider using PASV.
    150 Opening BINARY mode data connection for file2.txt (47 bytes).
    226 File send OK.
    47 bytes received in 0.00 secs (88.3 kB/s)
    local: file3.txt remote: file3.txt
    200 PORT command successful. Consider using PASV.
    150 Opening BINARY mode data connection for file3.txt (47 bytes).
    226 File send OK.
    47 bytes received in 0.00 secs (136.2 kB/s)
    local: file4.txt remote: file4.txt
    200 PORT command successful. Consider using PASV.
    150 Opening BINARY mode data connection for file4.txt (47 bytes).
    226 File send OK.
    47 bytes received in 0.00 secs (136.6 kB/s)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Archive

    Translate this page

     

    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here