DevReview.net

More development notices …

Archive for the ‘Other’ Category

FreeBSD / OpenBSD: PF Firewall Filter Large Number Of Subnets and IP Address

leave a comment

Q. How do I filter larger number of subnets and IPs using OpenBSD’s pf firewall under FreeBSD 7.x server? How do I log all dropped packets from such ips? How do I block upto 10000 IPs or subnet without any performance penalty?

A. You can easily filter large number of IPs or subnets using pf firewall. PF provides tables to hold large number of IPv4 and IPv6 address. Lookups against a table are very fast and consume less memory and processor time. Tables are created in pf.conf file. Tables can also be populated from text files containing a list of IP addresses and networks.

How do I configure tables to drop large number of IPs?

Open pf.conf file, enter:
# vi /etc/pf.conf
Add following code:
table <blockedips> persist file "/etc/pf.blocked.ip.conf"
ext_if="em1" # interface connected to internet

Add following code to drop and log all ips / subnet listed in /etc/pf.blocked.ip.conf, file
block drop in log (all) quick on $ext_if from <blockedips> to any
Save and close the file. Now create file /etc/pf.blocked.ip.conf file using vi text editor, enter:
vi /etc/pf.blocked.ip.conf
Sample output:

192.168.1.0/24
202.54.1.5
# 202.54.4.5

The file /etc/pf.blocked.ip.conf should contain a list of IP addresses and/or CIDR network blocks, one per line. Any line beginning with # is treated as a comment and ignored by pf. To load new rules, simply type:
# pfctl -nf /etc/pf.conf
# pfctl -f /etc/pf.conf

How do I view all IP address listed in tables?

Type the following command
# pfctl -t blockedips -T show
Sample output:

   58.65.232.0/21
   58.83.12.0/22
   64.28.176.0/20
   64.255.128.0/19
   66.231.64.0/20
   67.213.128.0/20
   69.8.176.0/20

How do I add subnet called 91.196.232.0/22 on the fly?

Use pfctl command itself, to add CIDR or IP on fly, enter:
# pfctl -t blockedips -T add 202.54.11.11
# pfctl -t blockedips -T add 91.196.232.0/22

How do I delete subnet called 91.196.232.0/22 on the fly?

Type the command as follows:
# pfctl -t blockedips -T delete 91.196.232.0/22
Please note that all changes made using pfct are dynamic. You need to update your file on disk to save the changes.

How do I see statistics for each IP / CIDR?

The -v option can display statistics for each table entry (IP/CIDR), enter:
# pfctl -t blockedips -T show -v
Sample output:

   216.243.240.0/20
        Cleared:     Thu Jul 10 03:01:01 2008
        In/Block:    [ Packets: 0                  Bytes: 0                  ]
        In/Pass:     [ Packets: 0                  Bytes: 0                  ]
        Out/Block:   [ Packets: 0                  Bytes: 0                  ]
        Out/Pass:    [ Packets: 0                  Bytes: 0                  ]
   216.255.176.0/20
        Cleared:     Thu Jul 10 03:01:01 2008
        In/Block:    [ Packets: 0                  Bytes: 0                  ]
        In/Pass:     [ Packets: 0                  Bytes: 0                  ]
        Out/Block:   [ Packets: 0                  Bytes: 0                  ]
        Out/Pass:    [ Packets: 0                  Bytes: 0                  ]

How do I view log of dropped IP from default /var/log/pflog file?

Use tcpdump command to read a log file:
# tcpdump -n -e -ttt -r /var/log/pflog
# tcpdump -n -e -ttt -r /var/log/pflog port 80
# tcpdump -n -e -ttt -r /var/log/pflog and host 202.33.1.2

You can also view log in real time, enter:
# tcpdump -n -e -ttt -i pflog0
# tcpdump -n -e -ttt -i pflog0 port 80
# tcpdump -n -e -ttt -i pflog0 host 202.33.1.2

Article copy pasted from here: http://www.cyberciti.biz/faq/opebsd-pf-firewall-block-subnets-ip-address/

Written by admin

September 1st, 2011 at 12:09 pm

Posted in Other

Install samba on freebsd

leave a comment

How to install samba on freebsd if its intsalled on vmware from host machine where installed windows

1. Install samba via ports, make install clean
Lets assume that username is “hockey”

2. put in rc.conf

nmbd_enable="YES"
smbd_enable="YES"

Read the rest of this entry »

Written by admin

April 16th, 2011 at 4:24 pm

Posted in Other

Tagged with ,

How to svn:ignore for directory or file

leave a comment

First of all remove old not needed resources from svn and local copy.

On top level use command:

here is directory structure  sample:

\application
    \files
    \tmp
> svn st
M  files
?  tmp

set the ignore property for tmp

> svn propedit svn:ignore ./
In opened vi editor add newlines what should be ignored, in mine example its just “tmp”.
Dont forget commit changed ./ dir.
how to check what props are set? :
> svn proplist
Properties on '.':
  svn:ignore

to see the value of svn:ignore

> svn propget svn:ignore
tmp

how to delete svn:ignore?
1. just use "svn propedit" again and remove what should be removed
or totally remove properties from dir:
2. svn propdel svn:ignore ./ 

end.

Written by admin

December 16th, 2010 at 12:57 am

Posted in Other

Install maven on freebsd

leave a comment

Maven’s Objectives

Maven’s primary goal is to allow a developer to comprehend the complete state of a development effort in the shortest period of time. In order to attain this goal there are several areas of concern that Maven attempts to deal with:

  • Making the build process easy
  • Providing a uniform build system
  • Providing quality project information
  • Providing guidelines for best practices development
  • Allowing transparent migration to new features

Read the rest of this entry »

Written by admin

November 11th, 2010 at 3:21 am

Posted in Other

Tagged with , , , ,

Facebook statistics

leave a comment

Statistics
People on Facebook

* More than 500 million active users
* 50% of our active users log on to Facebook in any given day
* Average user has 130 friends
* People spend over 700 billion minutes per month on Facebook

Activity on Facebook

* There are over 900 million objects that people interact with (pages, groups, events and community pages)
* Average user is connected to 80 community pages, groups and events
* Average user creates 90 pieces of content each month
* More than 30 billion pieces of content (web links, news stories, blog posts, notes, photo albums, etc.) shared each month.

Read the rest of this entry »

Written by admin

October 31st, 2010 at 8:24 pm

Posted in Other

Tagged with ,

Mediator design pattern

leave a comment

The Mediator defines an object that controls how a set of objects interact. Loose coupling between colleague objects is achieved by having colleagues communicate with the Mediator, rather than with each other. The control tower at a controlled airport demonstrates this pattern very well. The pilots of the planes approaching or departing the terminal area communicate with the tower rather than explicitly communicating with one another. The constraints on who can take off or land are enforced by the tower. It is important to note that the tower does not control the whole flight. It exists only to enforce constraints in the terminal area.

Read the rest of this entry »

Written by admin

August 16th, 2010 at 1:01 am

Posted in Other

Command design pattern

leave a comment

In object-oriented programming, the command pattern is a design pattern in which an object is used to represent and encapsulate all the information needed to call a method at a later time. This information includes the method name, the object that owns the method and values for the method parameters.

Three terms always associated with the command pattern are client, invoker and receiver. The client instantiates the command object and provides the information required to call the method at a later time. The invoker decides when the method should be called. The receiver is an instance of the class that contains the method’s code.

Read the rest of this entry »

Written by admin

August 15th, 2010 at 11:56 pm

Chain of responsibility design pattern

leave a comment

Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.

Read the rest of this entry »

Written by admin

August 15th, 2010 at 10:56 pm