{"id":34,"date":"2006-07-12T13:01:46","date_gmt":"2006-07-12T11:01:46","guid":{"rendered":"http:\/\/www.hackenberger.at\/wordpress\/?page_id=34"},"modified":"2006-07-12T13:30:41","modified_gmt":"2006-07-12T11:30:41","slug":"how-to-set-up-a-linux-box-as-a-bluetooth-server","status":"publish","type":"page","link":"https:\/\/www.hackenberger.at\/blog\/linux-guides\/gentoo-guides\/how-to-set-up-a-linux-box-as-a-bluetooth-server\/","title":{"rendered":"Bluetooth Server Howto"},"content":{"rendered":"<p><strong>Instructions how to set up a Linux box as a Bluetooth server<br \/>\n<\/strong><\/p>\n<p>Install the following packages (version number tested in brackets)<\/p>\n<p>bluez-bluefw (1.0)<br \/>\nbluez-hcidump (1.8)<br \/>\nbluez-libs (2.5)<br \/>\nbluez-pan (1.1)<br \/>\nbluez-sdp (1.5)<br \/>\nbluez-utils (2.5)<br \/>\nNext you have to configure your kernel to include all Bluetooth modules \t\t\t\tyou find. Configure them all as modules. (Tested with kernel 2.6.4)<\/p>\n<p>Write the following to \/etc\/modules.d\/bluez:<br \/>\nalias net-pf-31 bluez<br \/>\nalias bt-proto-0 l2cap<br \/>\nalias bt-proto-2 sco<br \/>\nalias bt-proto-3 rfcomm<br \/>\nalias bt-proto-4 bnep<br \/>\nalias tty-ldisc-15 hci_uart<br \/>\nalias char-major-10-250 hci_vhci<\/p>\n<p>Execute &#8220;update-modules&#8221; to update your modules.conf file.<\/p>\n<p>Now you have to configure the hcid. Edit \/etc\/bluetooth\/hcid.conf:<br \/>\nReplace the line:<br \/>\nlm accept;<br \/>\nwith:<br \/>\nlm accept,master;<br \/>\nAnd uncomment the lines:<br \/>\n#auth enable;<br \/>\n#encrypt enable;<br \/>\nTo enable authentification and encryption.<br \/>\nNow it&#8217;s time to set a pin:<br \/>\necho &#8220;yourPin&#8221; > \/etc\/bluetooth\/pin<br \/>\nwhich will overwrite the script there (it&#8217;s wrong anyway)<br \/>\nNow start the bluetooth services:<br \/>\n\/etc\/init.d\/bluetooth start<br \/>\nand start the pand by hand:<br \/>\npand &#8211;listen &#8211;role NAP &#8211;service NAP<br \/>\nNow you should be able to establish a connection from another \t\t\t\tbluetooth pc to you Linux Box using &#8220;yourPin&#8221;.<\/p>\n<p>But even if you now have a connection from your client pc to \t\t\t\tyour Linux Server, you would have to configure the network settings \t\t\t\tby hand, which is not quite handy.<\/p>\n<p>The solution is the dhcpd. Install the dhcp package, go to: \t\t\t\t\/etc\/dhcp\/ and copy the dhcpd.conf.sample to dhcpd.conf. open \t\t\t\tthe file in you favorite editor and configure it to look as follows:<br \/>\nbluez-hcidump (1.8)<br \/>\nbluez-libs (2.5)<br \/>\nbluez-pan (1.1)<br \/>\nbluez-sdp (1.5)<br \/>\nbluez-utils (2.5)<br \/>\nNext you have to configure your kernel to include all Bluetooth modules \t\t\t\tyou find. Configure them all as modules. (Tested with kernel 2.6.4)<\/p>\n<p>Write the following to \/etc\/modules.d\/bluez:<br \/>\nalias net-pf-31 bluez<br \/>\nalias bt-proto-0 l2cap<br \/>\nalias bt-proto-2 sco<br \/>\nalias bt-proto-3 rfcomm<br \/>\nalias bt-proto-4 bnep<br \/>\nalias tty-ldisc-15 hci_uart<br \/>\nalias char-major-10-250 hci_vhci<\/p>\n<p>Execute &#8220;update-modules&#8221; to update your modules.conf file.<\/p>\n<p>Now you have to configure the hcid. Edit \/etc\/bluetooth\/hcid.conf:<br \/>\nReplace the line:<br \/>\nlm accept;<br \/>\nwith:<br \/>\nlm accept,master;<br \/>\nAnd uncomment the lines:<br \/>\n#auth enable;<br \/>\n#encrypt enable;<br \/>\nTo enable authentification and encryption.<br \/>\nNow it&#8217;s time to set a pin:<br \/>\necho &#8220;yourPin&#8221; > \/etc\/bluetooth\/pin<br \/>\nwhich will overwrite the script there (it&#8217;s wrong anyway)<br \/>\nNow start the bluetooth services:<br \/>\n\/etc\/init.d\/bluetooth start<br \/>\nand start the pand by hand:<br \/>\npand &#8211;listen &#8211;role NAP &#8211;service NAP<br \/>\nNow you should be able to establish a connection from another \t\t\t\tbluetooth pc to you Linux Box using &#8220;yourPin&#8221;.<\/p>\n<p>But even if you now have a connection from your client pc to \t\t\t\tyour Linux Server, you would have to configure the network settings \t\t\t\tby hand, which is not quite handy.<\/p>\n<p>The solution is the dhcpd. Install the dhcp package, go to: \t\t\t\t\/etc\/dhcp\/ and copy the dhcpd.conf.sample to dhcpd.conf. open \t\t\t\tthe file in you favorite editor and configure it to look as follows:<\/p>\n<blockquote>\n<pre># dhcpd.conf\r\n#\r\n# Sample configuration file for ISC dhcpd\r\n#\r\n\r\n# option definitions common to all supported networks...\r\noption domain-name \"hackenberger.at\";\r\n#option domain-name-servers ns1.example.org, ns2.example.org;\r\noption domain-name-servers 195.34.133.10, 195.34.133.11;\r\n\r\ndefault-lease-time 600;\r\nmax-lease-time 7200;\r\n\r\n# If this DHCP server is the official DHCP server for the local\r\n# network, the authoritative directive should be uncommented.\r\n#authoritative;\r\n\r\n# Use this to send dhcp log messages to a different log file (you also\r\n# have to hack syslog.conf to complete the redirection).\r\nlog-facility local7;\r\n\r\n# No service will be given on this subnet, but declaring it helps the\r\n# DHCP server to understand the network topology.\r\n\r\n#subnet 10.0.0.0 netmask 255.255.255.0 {\r\n#}\r\n\r\n# This is a very basic subnet declaration.\r\n\r\nsubnet 10.0.0.0 netmask 255.255.255.0 {\r\nrange 10.0.0.10 10.0.0.20;\r\n#  option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;\r\noption routers 10.0.0.1;\r\n}\r\n\r\n# This declaration allows BOOTP clients to get dynamic addresses,\r\n# which we don't really recommend.\r\n\r\n#subnet 10.254.239.32 netmask 255.255.255.224 {\r\n#  range dynamic-bootp 10.254.239.40 10.254.239.60;\r\n#  option broadcast-address 10.254.239.31;\r\n#  option routers rtr-239-32-1.example.org;\r\n#}\r\n\r\n# A slightly different configuration for an internal subnet.\r\n#subnet 10.5.5.0 netmask 255.255.255.224 {\r\n#  range 10.5.5.26 10.5.5.30;\r\n#  option domain-name-servers ns1.internal.example.org;\r\n#  option domain-name \"internal.example.org\";\r\n#  option routers 10.5.5.1;\r\n#  option broadcast-address 10.5.5.31;\r\n#  default-lease-time 600;\r\n#  max-lease-time 7200;\r\n#}\r\n\r\n# Hosts which require special configuration options can be listed in\r\n# host statements.   If no address is specified, the address will be\r\n# allocated dynamically (if possible), but the host-specific information\r\n# will still come from the host declaration.\r\n\r\n#host passacaglia {\r\n#  hardware ethernet 0:0:c0:5d:bd:95;\r\n#  filename \"vmunix.passacaglia\";\r\n#  server-name \"toccata.fugue.com\";\r\n#}\r\n\r\n# Fixed IP addresses can also be specified for hosts.   These addresses\r\n# should not also be listed as being available for dynamic assignment.\r\n# Hosts for which fixed IP addresses have been specified can boot using\r\n# BOOTP or DHCP.   Hosts for which no fixed address is specified can only\r\n# be booted with DHCP, unless there is an address range on the subnet\r\n# to which a BOOTP client is connected which has the dynamic-bootp flag\r\n# set.\r\n#host fantasia {\r\n#  hardware ethernet 08:00:07:26:c0:a5;\r\n#  fixed-address fantasia.fugue.com;\r\n#}\r\n\r\n# You can declare a class of clients and then do address allocation\r\n# based on that.   The example below shows a case where all clients\r\n# in a certain class get addresses on the 10.17.224\/24 subnet, and all\r\n# other clients get addresses on the 10.0.29\/24 subnet.\r\n\r\n#class \"foo\" {\r\n#  match if substring (option vendor-class-identifier, 0, 4) = \"SUNW\";\r\n#}\r\n\r\n#shared-network 224-29 {\r\n#  subnet 10.17.224.0 netmask 255.255.255.0 {\r\n#    option routers rtr-224.example.org;\r\n#  }\r\n#  subnet 10.0.29.0 netmask 255.255.255.0 {\r\n#    option routers rtr-29.example.org;\r\n#  }\r\n#  pool {\r\n#    allow members of \"foo\";\r\n#    range 10.17.224.10 10.17.224.250;\r\n#  }\r\n#  pool {\r\n#    deny members of \"foo\";\r\n#    range 10.0.29.10 10.0.29.230;\r\n#  }\r\n#}\r\n\r\n# This is for DNS server updates:\r\nddns-update-style interim;<\/pre>\n<\/blockquote>\n<p>Now you have to connect the client to your pc (to get the netwok \t\t\t\tinterface bnep0. After connecting you gave to bring the interface \t\t\t\tup:<br \/>\nifconfig bnep0 up<br \/>\nand assign an ip address to it:<br \/>\nifconfig bnep0 10.0.0.1<br \/>\nThen start the dhcpd by invoking:<br \/>\n\/etc\/init.d\/dhcp start<br \/>\nNow you just have to enable IP-MASQUERADING (assuming you \t\t\t\thave all the necessary kernel modules and the iptables package \t\t\t\tinstalled):<br \/>\niptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE<br \/>\necho &#8220;1&#8221; > \/proc\/sys\/net\/ipv4\/ip_forward<\/p>\n<p>And voila&#8217;, after re-requesting the IP-address on your  \t\t\t\tclient you can enjoy the net on your client.  \t\t\t\tBut be careful not to terminate the connection when \t\t\t\treacquireing the IP address)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Instructions how to set up a Linux box as a Bluetooth server Install the following packages (version number tested in brackets) bluez-bluefw (1.0) bluez-hcidump (1.8) bluez-libs (2.5) bluez-pan (1.1) bluez-sdp (1.5) bluez-utils (2.5) Next you have to configure your kernel to include all Bluetooth modules you find. Configure them all as modules. (Tested with kernel &hellip; <a href=\"https:\/\/www.hackenberger.at\/blog\/linux-guides\/gentoo-guides\/how-to-set-up-a-linux-box-as-a-bluetooth-server\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Bluetooth Server Howto<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":35,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.hackenberger.at\/blog\/wp-json\/wp\/v2\/pages\/34"}],"collection":[{"href":"https:\/\/www.hackenberger.at\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.hackenberger.at\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.hackenberger.at\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hackenberger.at\/blog\/wp-json\/wp\/v2\/comments?post=34"}],"version-history":[{"count":0,"href":"https:\/\/www.hackenberger.at\/blog\/wp-json\/wp\/v2\/pages\/34\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.hackenberger.at\/blog\/wp-json\/wp\/v2\/pages\/35"}],"wp:attachment":[{"href":"https:\/\/www.hackenberger.at\/blog\/wp-json\/wp\/v2\/media?parent=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}