bluetooth network with bluez4 and udev 
Many things changed for bluez4. Now everything is made through dbus commands.

apt-get install bluetooth bluez (on server and client)

First check for bdaddr on server and client:

Server:> hcitool dev
Devices:
hci0 00:01:1A:63:49:33

Client:> hcitool dev
Devices:
hci0 00:02:6E:53:42:78

Pairing:

Server:> /usr/share/doc/bluez/examples/test-adapter discoverable on
Server:> /usr/share/doc/bluez/examples/simple-agent

Client:> /usr/share/doc/bluez/examples/simple-agent 00:02:6E:53:42:78 00:01:1A:63:49:33

Hint: On newer systems use /usr/bin/bluez-test-adapter, /usr/bin/bluez-simple-agent and bluez-test-network

On Server:
Agent registered
RequestPinCode (/org/bluez/25897/hci0/dev_00_02_6E_53_42_78)
Enter PIN Code: 1234
(keep simple-agent running)

On Client:
RequestPinCode (/org/bluez/4078/hci0/dev_00_01_1A_63_49_33)
Enter PIN Code: 1234
Release
New device (/org/bluez/4078/hci0/dev_00_01_1A_63_49_33)

Pairing keys are stored hashed in /var/lib/bluetooth/<local bdaddr>/linkkeys

Network:
--- /usr/share/doc/bluez/examples/test-network
+++ /usr/share/doc/bluez/examples/test-network.sh
@@ -35,9 +35,10 @@
print "Press CTRL-C to disconnect"

try:
- time.sleep(1000)
- print "Terminating connection"
+ while 1:
+ time.sleep(1000)
except:
pass

+print "Terminating connection"
network.Disconnect()
Client:> /usr/share/doc/bluez/examples/test-network.sh 00:01:1A:63:49:33
(keep test-network running)

On Server:
Authorize (/org/bluez/25897/hci0/dev_00_02_6E_53_42_78, 0000000f-0000-1000-8000-00803f9b24fa)
Authorize connection (yes/no): yes

Now you can stop simple-agent.

Server:> ifconfig ifconfig bnep0 192.168.0.1 netmask 255.255.255.0 up
Client:> ifconfig ifconfig bnep0 192.168.0.2 netmask 255.255.255.0 up

Now you can ping each other.

To avoid start simple-agent on server for connection authorisation each time you can trust the client with:

Server:> /usr/share/doc/bluez/examples/test-device trusted 00:01:1A:63:49:33 on

Automatisation:

On my server i'm running a bridged network with dhcp support, therefore i use udev to add bnep to my bridge:

/etc/udev/rules.d/local.rules:
ACTION=="add", SUBSYSTEM=="net", KERNEL=="bnep?*", PROGRAM="/usr/sbin/brctl addif br0 %k"

Client:

/etc/udev/rules.d/local.rules:
ACTION=="add", SUBSYSTEM=="net", KERNEL=="bnep?*", PROGRAM="/sbin/dhclient -nw -pf /var/run/dhclient-%k.pid %k"
ACTION=="remove", SUBSYSTEM=="net", KERNEL=="bnep?*", PROGRAM="/usr/bin/pkill -9 dhclient"

maybe you need to reload udev!

On clientside you only have to keep running
/usr/share/doc/bluez/examples/test-network.sh 00:01:1A:63:49:33

Usually this should be done by networkmanager but this is not supported (now)

[ view entry ] ( 2632 views )   |  print article
dnstunnel with iodine and bind9 
Iodine server with public IP:

#> apt-get install iodine

For "good" connection i used a mtu of 256 through my provider DNS.
On local network no mtu change was necessary.

/etc/default/iodine
START_IODINED="true"
IODINED_ARGS="-m 256 -l IODINE_SERVER_IP 10.0.0.1 tunnel.DOMAIN"
IODINED_PASSWORD="mypassword"
#> sysctl -e net.ipv4.ip_forward=1
#> iptables -t nat -A POSTROUTING -s 10.0.0.0/255.255.255.0 -o eth0 -j MASQUERADE

Bind9 server:

zonesfile:
zone "DOMAIN" in {
type master;
file "/etc/bind/zones/DOMAIN";
allow-query { any; };
};

zone "tunnel.DOMAIN" in {
type forward;
forward only;
forwarders {
IODINE_SERVER_IP;
};
};
zonefile:
tunnel      1D   IN   NS    tunnelhost
tunnelhost 1D IN A IODINE_SERVER_IP

Client:

#> apt-get install iodine
#> iodine -m 256 -P mypassword tunnel.DOMAIN
#> route add default gw 10.0.0.1


Well it seams that my provider drop's packets with some payload in it:

#> ping -c1 -s 109 10.0.0.1 fails

but

#> ping -c1 -s 109 -p ff 10.0.0.1 succeeds


[ view entry ] ( 1441 views )   |  print article
chrooted sftp only 
useradd -s /bin/false -m SFTPUSER
mkdir /home/SFTPUSER/.ssh
ssh-keygen -t rsa -b 2048 -N '' -f /home/SFTPUSER/.ssh/id_rsa
chown -R SFTPUSER:SFTPUSER /home/SFTPUSER/.ssh
chmod 600 /home/SFTPUSER/.ssh/id_rsa

/etc/ssh/sshd_config:
Subsystem       sftp    internal-sftp

Match user SFTPUSER
PasswordAuthentication no
AllowTcpForwarding no
X11Forwarding no
ForceCommand internal-sftp
ChrootDirectory /chroot
chown root:root /chroot
mkdir /chroot/SFTPUSERDIR
chown SFTPUSER:SFTPUSER /chroot/SFTPUSERDIR

echo "put FILENAME" | \
sftp -oIdentityFile=/home/SFTPUSER/.ssh/id_rsa \
-oTCPKeepAlive=no -oServerAliveInterval=15 \
SFTPUSER@localhost:SFTPUSERDIR


[ view entry ] ( 2469 views )   |  print article
secure rsync to only one directory 
I want to rsync to a remote host to a given directory.

local-host:
ssh-keygen -t rsa
keyfilename: ~/.ssh/rsync
ssh-copy-id -i .ssh/rsync rsyncuser@remote-host

rsync files with ssh:
rsync -vaHxr --delete \
-e "ssh -i ~/.ssh/rsync -c arcfour -o Compression=no -x" \
LOCALDIR rsyncuser@remote-host:

remote-host

/home/rsyncuser/.ssh/authorized_keys:
from="192.168.0.2,",command="/home/rsyncuser/validate-rsync.sh",
no-pty,no-agent-forwarding,no-port-forwarding
ssh-dss 012345678...
limit access with from (optional).
On sucessfully ssh login command is executed.
Read More...

[ view entry ] ( 2487 views )   |  print article
ip crossover: send packets on eth0 out and receive them via eth1  
For testing my intellon driver on one pc i need to send packets on eth0 (intellon usb) out and receive them via eth1 (intellon ethernet).

The only solution i found was a not anymore supported module for netfilter from Rusty Russell.

I tried to fix the compiler errors/warnings and finally it worked.

Usage:

ifconfig eth0 192.168.1.1
ifconfig eth1 192.168.2.1
arp -s 192.168.1.2 <hardware address of eth1> -i eth0
arp -s 192.168.2.2 <hardware address of eth0> -i eth1
modprobe ip_crossover dev1=eth0 dev2=eth1

Then doing ping 192.168.1.2, ICMP ping goes out eth0 and comes back in eth1.

ip_crossover.tar.bz2


for testing packets with differenz sizes i did:

for i in $(seq 0 1472); do ping -q -c1 -s$i 192.168.2.2 >/dev/null || echo fail $i; done

for i in $(seq 0 1472); do ping -q -c1 -s$i 192.168.1.2 >/dev/null || echo fail $i; done


[ view entry ] ( 1530 views )   |  print article

<<First <Back | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Next> Last>>