2008年4月30日 星期三

bridge on linux

Net:Bridge - The Linux Fundation good introduction.

ebtables - Ethernet-Bridge-tables a filter tool for ethernet bridge as iptables for ip traffics.

2008年4月29日 星期二

Mick Bauer's articles on LinuxJournal

Mick Bauer's articles on LinuxJournal

vpn solutions

tinc

vpnd (Virtual Private Network Daemon)

PPTP server for Linux
PPTP client for Linux

zorp I/II

Links:
[1] http://www.linuxjournal.com/files/linuxjournal.com/linuxjournal/articles/072/7296/7296f1.png
[2] http://www.linuxjournal.com/files/linuxjournal.com/linuxjournal/articles/072/7296/7296f2.png
[3] http://www.balabit.com
[4] http://www.balabit.com/products/oss/tproxy
[5] http://www.balabit.com/downloads
[6] http://www.balabit.com/products/zorp_gpl/tutorial

Links:
[1] http://www.balabit.com/products/oss/tproxy
[2] http://www.balabit.com/products/zorp_gpl
[3] http://www.linuxjournal.com/files/linuxjournal.com/linuxjournal/articles/073/7347/7347f1.png
[4] http://www.balabit.com/downloads/zorp/zorp-os/pool/i/iptables-utils
[5] http://www.linuxjournal.com/files/linuxjournal.com/linuxjournal/articles/073/7347/7347f2.png
[6] http://www.balabit.com
[7] http://www.balabit.com/downloads/zorp/zorp-os
[8] https://lists.balabit.hu/mailman/listinfo/zorp

transparent proxy for squid in bridge configuration

Squid Config Example
Fully Transparent With TPROXY

Linux: Setup a transparent proxy with Squid in three easy steps

Squid Cache, TProxy, dan Mikrotik (Alternate Configuration for Simple Networks)

Configuring a Transparent Proxy/Webcache in a Bridge using Squid and ebtables

Squid 2.6 + tproxy + bridge + gentoo

To configure a bridge interface

ifconfig eth0 0.0.0.0 promisc up
ifconfig eth1 0.0.0.0 promisc up

brctl addbr br0
brctl addif br0 eth0
brctl addif br0 eth1

ifconfig br0 200.1.2.3 netmask 255.255.255.0 up
route add default gw 200.1.2.254 dev br0


To intercept the concerned connections:

bash# ebtables -t broute -A BROUTING -p IPv4 --ip-protocol 6 \
--ip-destination-port 80 -j redirect --redirect-target ACCEPT

bash# iptables -t nat -A PREROUTING -i br0 -p tcp --dport 80 \
-j REDIRECT --to-port 3128

The first command says that packets passing through the bridge going to port 80 will be redirected to the local machine, instead of being bridged. The second uses iptables to redirect those packets to local port 3128, so squid can take care of them.

2008年4月2日 星期三

iptables TPROXY target

2007-09-30 20:51:41 GMT, KOVACS Krisztian posted a series of patchs for TPROXY: [PATCH 00/13] Transparent Proxying Patches, Take 3

2007-10-02 20:37:56 GMT, KOVACS Krisztian: Transparent proxy patches, take 4 - userspace
2007-10-02 20:39:42 GMT, KOVACS Krisztian: [PATCH 00/13] Transparent Proxying Patches, Take 4

2007-10-13 17:28:57 GMT, KOVACS Krisztian posted a series of patchs for TPROXY: [PATCH 00/14] Transparent Proxying Patches, Take 5

there is a lot of patches in http://people.netfilter.org/hidden/tproxy/

Squid (WWW Proxy Server)/TPROXY Rules

Transparent Proxy with Linux and Squid mini-HOWTO

LVS and transparent proxy

[stunnel-users] [stunnel patch] transparent proxy on linux 2.6 using cttproxy patch

fedora download


===========================================================================
RedHat EL5.0 上で kernel2.6(tproxy2.0.6パッチ付き)をビルドする方法(メモ)
Ver1.00 2007/08/31 吉岡
===========================================================================


1. Linux Kernelをkernel.orgから入手・展開
入手元: http://kernel.org/
(ここではlinux-2.6.20.18.tar.bz2を利用)
# cd /usr/src/
# wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.20.18.tar.bz2
# tar -jxvf linux-2.6.20.18.tar.bz2

2. tproxyパッチを入手・適用
入手元: http://www.balabit.com/downloads/files/tproxy/obsolete/linux-2.6/cttproxy-2.6.20-2.0.6.tar.gz
# cd /usr/src
# wget http://www.balabit.com/downloads/files/tproxy/obsolete/linux-2.6/cttproxy-2.6.20-2.0.6.tar.gz
# tar -zxvf cttproxy-2.6.20-2.0.6.tar.gz
# mv linux-2.6.20.18 linux-2.6.20.18-tproxy
# cd linux-2.6.20.18-tproxy/
# cat ../linux-2.6.20.18-tproxy/patch_tree/* | patch -p1

3. Kernelを設定
# cd linux-2.6.20.18-tproxy/
# make menuconfig
以下のように設定変更
- General setup
- Local version: (-tproxy)
- Networking
- Networking options
- Network packet filtering framework (Netflter)
- Core Netfilter Configuration
(M) Netfilter connection tracking support
Netfilter connection tracking support
=> (X) "Layer 3 Dependent Connection tracking (OBSOLETE)"
- IP: Netfilter Configuration
(M) Full NAT (NEW)
(M) MASQUERADE target support
(M) REDIRECT target support
[*] NAT reservations support
(M) FTP protocol support
(M) Transparent proxying
(M) tproxy match support
(M) TPROXY target support
- Device Drivers
- Network device support
利用しているインターフェースのドライバを指定
([M]又は[*]で組み込み。)
  設定が終了したら[Exit]で終了し、設定を保存(Yes)。

4. Kernelのビルド
# make

5. Kernelのインストール
# make modules_install
# cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.20.18-tproxy
# mkinitrd /boot/initrd-2.6.20.18-tproxy.img 2.6.20.18-tproxy
(上書きする場合、mkinitrdに"-f"を追加)

6. grub.confの書き換え
以下のように設定ファイルに変更します。
ファイル: /etc/grub.conf
追加内容:
===================================================
title Red Hat Enterprise Linux Server (2.6.20.18-tproxy)
root (hd0,0)
kernel /vmlinuz-2.6.20.18-tproxy ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.20.18-tproxy.img
===================================================

7. マシンをリブートし、ブート時にKernelとして2.6.20.18-tproxyを選択。

8. 以下のFAQに従ってtproxyを設定
■54028: 透過プロキシ型の場合にクライアントのソースIPアドレスを保持することはできますか?
(http://www.f-secure.co.jp/support/html/linux_gw_54028.html)

2008年3月26日 星期三

stunnel to establish a mutual-certificated SSL tunnel

stunnel could be used to establish SSL tunnel for non-SSL connection. The scenario looks like

AP1 <-> [stunnel client] <- SSL connection -> [stunnel server] <-> AP2

stunnel client accepts a TCP connection, establish a SSL connection to stunnel server, and exchanges data between TCP connection and SSL connection,

stunnel server accepts a SSL connection, establish a TCP connection to AP2, and exchanges data between SSL connection and TCP connection.

In general, the SSL connection could be used to protect MIB to observe/intercept/modify the data in it. And only server-side SSL certificate is verified. But it is possible to let SSL server to verify the client-side SSL certificate.

Here is the procedure:

1. create key/certificate for client.
# openssl genrsa 1024 > client-key.pem
# openssl req -new -key client-key.pem -x509 -days 3650 -out client-cert.pem

2. create key/certificate for server.
# openssl genrsa 1024 > client-key.pem
# openssl req -new -key client-key.pem -x509 -days 3650 -out client-cert.pem

3. create stunnel config file for client.
cert = client-cert.pem
key = client-key.pem
chroot = /usr/local/stunnel/
setuid = nobody
setgid = nobody
pid = /client.pid
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
verify = 2
CApath = /client
client = yes

[ap1]
accept = 127.0.0.1:2399
connect = :2340
TIMEOUTclose = 0

4. create stunnel config file for server.
cert = server-cert.pem
key = server-key.pem
chroot = /usr/local/stunnel/
setuid = nobody
setgid = nobody
pid = /server.pid
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
verify = 2
CApath = /server

[ap2]
accept = :2340
connect = 127.0.0.1:2341
TIMEOUTclose = 0

5.
In host running ap1 and stunnel client, put client-key.pem/client-cert.pem in /usr/local/stunnel, and put server-cert.pem in /usr/local/stunnel/client. then run
# c_rehash /usr/local/stunnel/client

6.In host running ap2 and stunnel server, put server-key.pem/server-cert.pem in /usr/local/stunnel, and put client-cert.pem in /usr/local/stunnel/server. then run
# c_rehash /usr/local/stunnel/server

7. start the stunnel client/server.
In stunnel client host,
# stunnel /usr/local/stunnel/client.conf

In stunnel server host,
# stunnel /usr/local/stunnel/server.conf