4.2. Setting up a bridge

Bridge is an networking equipment that delivers IP packets from an network to another. To connect your PAN and LAN via bridge follow the instructions below.

  1. Edit Affix configuration file (/etc/affix/affix.conf). Check that PAN role "nap" is chosen. Comment other roles out. Check that "bridge" is selected as pan scheme (it is uncommented).

  2. Restart PAN:

    btpan stop

    btpan init nap

    You need to restart PAN only this time. Next time you reboot your computer PAN is initialized automatically as NAP.

  3. Edit /etc/network/interfaces file. First, let's set up the bridge configuration. Here you have two options. If your network connection is set up using DHCP add the following lines to the file. Replace eth0 with your network interface name.

    Example 4-1. Bridge setup via dhcp

    auto br0
    iface br0 inet dhcp
      pre-up ifconfig eth0 down
      pre-up brctl addbr br0
      pre-up brctl addif br0 eth0
      pre-up ifconfig eth0 up
      post-down ifconfig eth0 down
      post-down brctl delif br0 eth0

    In case you have static IP address add following lines to /etc/network/interfaces. Remember to replace tags below with your network information. Also if your network interface card uses some other interface than eth0 replace it too.

    Example 4-2. Bridge setup statically

    auto br0
    iface br0 inet static address <your_ip_address>
      netmask <your_net_mask>
      network <your_network>
      broadcast <your_network_broadcast_address>
      gateway <your_default_gateway>
      pre-up ifconfig eth0 down
      pre-up brctl addbr br0
      pre-up brctl addif br0 eth0
      pre-up ifconfig eth0 up
      post-down ifconfig eth0 down
      post-down brctl delif br0 eth0

    Eth0 is now included in your bridge configuration. We need to add an another interface there too. This will be your Bluetooth device's interface. It is probably pan0. Add the following lines to /etc/network/interfaces

    Example 4-3. Bluetooth device setup

    auto pan0
    iface pan0 inet manual
      pre-up brctl addbr br0
      pre-up brctl addif br0 $IFACE
      up ifconfig $IFACE 0.0.0.0 up
      down ifconfig $IFACE down
      post-down brctl delif br0 $IFACE
  4. It is recommended to install ifplugd (in Debian). It will automatically bring your Bluetooth interface up when you plug the Bluetooth dongle or PCMCIA card into your computer. After installing ifplugd edit /etc/default/ifplugd file. Add there line:

    INTERFACES="pan0"

    When you are setting your system up you need to bring bridge up manually . Give command

    ifup br0

    Next thime your computer is rebooted bridge is set up automatically. If you did not install ifplugd utility you have to bring up also Bluetooth device interface pan0 manually. Give command

    ifup pan0

Note! You do not need to enable IP forwarding or add rules to iptables when using bridge configuration. Next time when you will reboot the computer the bridge is set up automatically. You can now proceed setting the client computers (PANUs) up.