Sunday, October 4, 2009

Ethernet Bridge on FreeBSD

The basic operation of a bridge is to join two or more network segments together. There are many reasons to use a host based bridge over plain networking equipment such as cabling constraints, firewalling or connecting pseudo networks such as a Virtual Machine interface. A bridge can also connect a wireless interface to a wired network and act as an access point.

Two Physical (Real) Network Card (NIC) (minimum)

Enabling the Bridge:
The bridge is created using interface cloning.

To create a bridge use ifconfig

# ifconfig bridge create

# ifconfig bridge0
bridge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 96:3d:4b:f1:79:7a
        id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
        maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200
        root id 00:00:00:00:00:00 priority 0 ifcost 0 port 0

Add the member network interfaces to the bridge.

# ifconfig bridge0 addm re0 addm re1 up
# ifconfig re0 up
# ifconfig re1 up

To remove a BRIDGE interface, enter:
# ifconfig bridge0 destroy

To make configuration persistence, open /etc/rc.conf, Append / modify as follows:
# vi /etc/rc.conf
ifconfig_bridge0="addm re0 addm re1 up"

bridge interface can be configured to take part in network.
# ifconfig bridge0 inet

Linux Ethernet Bridge

The Linux ethernet bridge can be used for connecting multiple ethernet devices together. The connection is fully transparent: hosts connected to one ethernet device see hosts connected to the other ethernet devices directly.

  1. Two Physical (Real) Network Card (NIC) (minimum)
  2. bridge-utils - This package contains utilities for configuring the Linux ethernet bridge.
1. Zero IP the interfaces.
        # ifconfig eth0
        # ifconfig eth1


        # ifconfig eth0 up promisc
        # ifconfig eth1 up promisc

2. Create the bridge interface.
        # brctl addbr br0

3. Add interfaces to the bridge.
        # brctl addif br0 eth0
        # brctl addif br0 eth1


        # brctl addif br0 eth0 eth1

4. Put up the bridge.
        # ifconfig mybridge up

5. The virtual interface br0 can also be configured to take part in network. It behaves like real interface (like a normal network card).
        # ifconfig br0 netmask

Saturday, October 3, 2009

kill process based on username and logout users

To kill all process of logged in user and logout

pkill -KILL -u username

Ethernet Loopback connector

Occasionally I need for a network card to operate as a live network connection, without it actually being connected to a network. Typically for testing purposes, I need a quick and easy way to make a loopback connector. Small enough to keep in my Pocket. The following is a quick "how to" for making an Ethernet loopback connector.

To create a loopback plug, cross pin 1 (TX+) and pin 3 (RX+) together, and cross pin 2 (TX-) and pin 6 (RX-) together. You need the following equipment to create the loopback:

  • A 6-inch long CAT5 cable
  • An RJ-45 connector
  • A crimping tool

When you create and then test a physical loopback, you are testing the RJ-45 interface of the NIC.

Know Number of Logged in User in FreeRadius from Shell

This is a very useful perl script that i created to know how many user are logged in on FreeRadius from the UNIX/Linux shell or command line.

It’s for FreeRadius with MySQL and I think it is usefull for other radiuses as well.
Below is the full code.

#!/usr/bin/perl -w

use DBI;

my $db = 'radius';
my $db_host = 'localhost';
my $db_username = 'username';
my $db_password = 'password';
my $dbh = DBI->connect("dbi:mysql:database=$db;host=$db_host:port number;user=$db_username;password=$db_password") or die "Couldn't connect to database: $DBI::errstr\n";

my $sql = qq{SELECT DISTINCT UserName,AcctStartTime,FramedIPAddress,CallingStationId FROM radacct WHERE AcctStopTime = '0000-00-00 00:00:00' AND NASIPAddress = '' GROUP BY UserName};

$sth = $dbh->prepare($sql) or die "Couldn't prepare query '$sql': $DBI::errstr\n";

$sth->execute() or die "Couldn't execute query '$sql': $DBI::errstr\n";

print $sth->rows();




change the username and password to actual username and password of a MySQL database, and NASIPAddress.

MacJournal to WordPress

You can publish your MacJournal to WordPress.
(For custom configuration.)

Here’s the step-by-step guide:

1. Select your desired journal entry.
2. From the menu Entry, click Send to Blog.
3. Click Manual Setup
4. Type in Name : (your blog name)
5. In pull down menu,Type: select Movable Type
6. Type in URL:
7. Type in Post URL:
8. Type in Username : (your account name)
9. Type in Blog ID : 1
10. Press button Ok.