(一) 搭建Radius 服务器 这里使用的是 windows 2003 的IAS
1. 安装 IAS
2. 配置 IAS
A.新建 RADOUS 客户端
名称随便填,客户端的地址就是open***服务器地址
B 新建远程访问策略
授予 TelnetClients 组远程访问权限
重要:点击-〉编辑配置文件
身份验证选项卡 如下配置
Ok 确定之后 radius server 配置完成
接下来测试 radius 服务器
1.在服务器上 新建一个用户
用户名:*** 密码:test 加入 TelnetClients 组 确保它的“属性”中“拨入”选项卡的“远程访问权限”设置为 “通过远程访问策略控制访问”
2.查看服务端口是否开启
Radius 的常用端口
2.Windows pc 上使用软件ntradping 进行测试
提示:你需要为你的pc 在radius 服务器上也新建一个 RADIUS 客户端
在软件左上方中输入认证信息 –〉 接着点击下方的 send 按钮
A radius 服务器正常 但认证失败(用户没有权限/密码错误等)
B radius 认证成功
至此 raidus 服务器搭建完成
Popauth.pl
#!/usr/bin/perl # Write by ELM # wzk [A|T] wenzk [D|O|T] net # http://www.wenzk.net # # POP3 Auth script for Open××× # Usage: # save this file to /etc/open***/ as popauth.pl # run£º chmod +x /etc/open***/popauth.pl # add the next line to you Open××× config file # auth-user-pass-verify /etc/open***/popauth.pl via-env # restart your Open××× Server use Net::POP3; # POP Server Address $POPHOST = "localhost"; $USERNAME = $ENV{username}; $PASSWORD = $ENV{password}; # Constructors $pop = Net::POP3->new($POPHOST); $pop = Net::POP3->new($POPHOST, Timeout => 60); if ( defined $pop->login($USERNAME, $PASSWORD) ) { $result = 0; } else { $result = 1; } $pop->quit; exit $result;
centos yum 光盘源
2008-09-04 18:42
CentOS 4下Yum安装本地光盘软件 首先 要先挂载光盘,把光盘挂载到media/CentOS/,media/cdrom/,或者media/cdrecorder/这样就不用修改配置文件了。
命令: mount /dev/cdrom /media/cdrom
如果想挂载到其他目录,只要修改下baseurl=file:///自己挂载的目录,就可以了。配置文件在/etc/yum.repos.d/CentOS-Media.repo。
接着 把/etc/yum.repos.d/CentOS-Base.repo改下名,命令如下: QUOTE: #mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
检查下配置文件的有没设置正确,命令如下: QUOTE: # CentOS-Media.repo # # This repo is used to mount the default locations for a CDROM / DVD on# CentOS-4. You can use this repo and yum to install items directly off the # DVD ISO that we release. # # To use this repo, put in your DVD and use it with the other repos too:# yum --enablerepo=c4-media [command] # # or for ONLY the media repo, do this: # # yum --disablerepo=\* --enablerepo=c4-media [command] [c4-media] name=CentOS-$releasever - Media baseurl=file:///media/cdrom/ file:///media/cdrecorder/ gpgcheck=1 enabled=0 gpgkey=file:///usr/share/doc/centos-release-4/RPM-GPG-KEY-centos4
其实配置文件中已经有教怎么做的了,我好像是多此一举了。
最后 就是要安装软件咯,命令如下: yum --disablerepo=\* --enablerepo=c4-media install mysql-server
yum --disablerepo=\* --enablerepo=c4-media install mysql-devel
yum --disablerepo=\* --enablerepo=c4-media install curl
yum --disablerepo=\* --enablerepo=c4-media install php-mysql
yum --disablerepo=\* --enablerepo=c4-media install compat-libstdc++-33
yum --disablerepo=\* --enablerepo=c4-media install libtool
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum --disablerepo=\* --enablerepo=c4-media install mysql-server mysql-devel curl php-mysql compat-libstdc++-33 libtool net-snmp php-gd php-snmp perl-DateManip perl-MD5 net-snmp-utils freetype sudo mod_ssl
freeradius+open***+mysql实现 2009-01-15 16:17
分类: 技术归档
字号: 大 中 小
一、前言
具体的调用流程是:
win 的open***客户端通过 auth-user-pass认证模式(即通过ca.crt ta.key server.crt)到open***服务器,调用插件radiusplugin (/usr/local/open***/radiusplugin.so , /usr/local/open***/radiusplugin.cnf),radiusplugin调用 radiusd(name=127.0.0.1、sharedsecret= testing123和radius的服务端口),通过radiusd的clients.conf实现服务器的本身127.0.0.1密匙模式调用 radiusd,再通过radiusd.conf配置sql方式的认证,再到radiusd的sql.conf(通过rlm_sql_mysql调用)到 mysql数据库
具体的安装是上述调用的逆向过程
二、安装freeradius以及rlm_sql_mysql.so
1、 编译安装
(1)、编译安装freeradius
wget ftp://ftp.freeradius.org:/pub/radius/freeradius-1.1.7.tar.gz
tar zxvf freeradius-1.1.7.tar.gz
cd freeradius-1.1.7
./configure
cp libltdl/ltdl.h src/include/
make
make install
注释:如果没有cp libltdl/ltdl.h src/include/ 在make的时候会有2个错误,应该是路径的问题
(2)、安装rlm_sql_mysql相关
由于我的mysql是编译好的二进制包安装的,所以系统没有rlm_sql_mysql.so这个东西
所以要重新编译出rlm_sql_mysql.so这个东西来。
ln -s /usr/local/mysql/bin/mysql_config /sbin/mysql_config
cd /usr/local/src/freeradius-1.1.7/src/modules/rlm_sql/drivers/rlm_sql_mysql
./configure --with-mysql-dir=/usr/local/mysql --with-mysql-lib-dir=/usr/local/mysql/lib \
--with-mysql-include-dir=/usr/local/mysq/include
make
make install
这里的编译参数是根据每个人的实际情况设定的,这一步的编译要在freeradius编译安装后再做。
vi /etc/ld.so.conf
/usr/local/lib
ldconfig
2、构建radius数据库(建立相关用户和密码)
/usr/local/mysql/bin/mysql –uroot –pXXXX
mysql>create database radius;
mysql>GRANT ALL PRIVILEGES ON radius.* TO radius@localhost IDENTIFIED BY 'AAAA';
mysql>\q
cd /usr/local/src/freeradius-1.1.7
/usr/local/mysql/bin/mysql -uroot -pXXXX radius < ./doc/examples/mysql.sql
3、配置radiusd.conf以及sql.conf
(1)、radiusd.conf配置
vi /usr/local/etc/raddb/radiusd.conf
proxy_requests = no
authorize {
preprocess
chap
mschap
suffix
eap
sql
# pap
# files
}
注释:使用sql,authorize中的file必须被注释掉。
preacct {
preprocess
acct_unique
suffix
# files
}
accounting {
detail
unix
radutmp
sql
}
(2)、sql.conf配置
vi /usr/local/etc/raddb/sql.conf
driver = "rlm_sql_mysql"
server = "localhost"
login = "radius"
password = "AAAA"
radius_db = "radius"
配置NAS信息:
vi /usr/local/etc/raddb/clients.conf
#本地帐号,用于测试
client 127.0.0.1 {
secret = testing123
shortname = localhost
nastype = other
}
注释:
secret 这里是针对client 127.0.0.1通讯密匙
#mysql -u root -p
mysql> use radius;
建立组信息:
mysql> insert into radgroupreply (groupname,attribute,op,value) values ('user','Auth-Type',':=','Local');
mysql> insert into radgroupreply (groupname,attribute,op,value) values ('user','Service-Type',':=','Framed-User');
mysql> insert into radgroupreply (groupname,attribute,op,value) values ('user','Framed-IP-Address',':=','255.255.255.255');
mysql> insert into radgroupreply (groupname,attribute,op,value) values ('user','Framed-IP-Netmask',':=','255.255.255.0');
建立用户信息:
mysql> insert into radcheck (username,attribute,op,value) values ('test','User-Password',':=','test');
mysql> insert into radcheck (username,attribute,op,value) values ('sense','User-Password',':=','123456');
将用户加入组中:
mysql> insert into usergroup (username,groupname) values ('test','user');
注释:
对于 radcheck 这个表attribute的项有好几种设置的,我们设置的是认证的密码模式明码User-Password,也可以设置成加密Crypt-Password,如果是加密模式需要libgcrypt支持。
同时对于表radgroupreply中项attribute,的含义不是太明白:Auth-Type 、 Service-Type 、 Framed-IP-Address、 Framed-IP-Netmask、Acct-Interim-Interval
测试:
radiusd –x &
这个时候控制台会被占用
另开一个控制台进行测试
ln -s /usr/local/bin/radtest /sbin/radtest
/sbin/radtest test test localhost 0 testing123
Sending Access-Request of id 204 to 127.0.0.1 port 1812
User-Name = "test"
User-Password = "test"
NAS-IP-Address = 255.255.255.255
NAS-Port = 0
rad_recv: Access-Accept packet from host 127.0.0.1:1812, id=204, length=38
Service-Type = Framed-User
Framed-IP-Address = 255.255.255.255
Framed-IP-Netmask = 255.255.255.0
/sbin/radtest sense 123456 localhost 0 testing123
Sending Access-Request of id 212 to 127.0.0.1 port 1812
User-Name = "sense"
User-Password = "123456"
NAS-IP-Address = 255.255.255.255
NAS-Port = 0
rad_recv: Access-Accept packet from host 127.0.0.1:1812, id=212, length=20
由于test加入了组所以信息量多一点
以上测试说明freeradius-mysql工作正常!
说明(freeradius\rlm_sql_mysql.so\mysql\)正常!
三、 装Open×××
1、其中我的openssl我是系统自带的,所以不要再次安装
rpm -aq|grep openssl
openssl-devel-0.9.8b-8.3.el5
openssl-0.9.8b-8.3.el5
2、安装open***2.09
cd /usr/local/src
wget http://open***.net/release/open***-2.0.9.tar.gz
tar zxvf open***-2.0.9.tar.gz
cd open***-2.0.9
首先是看一下open***.spec里面对于liblzo1和openssl的版本要求,对照自己的版本看符合要求吗
检查pam-devel包是否安装,否则从系统盘安装改软件包,一般系统安装时都已经安装了
这一部分的pam不一定要安装,因为open***不是直接调用mysql的,如果是open***直接调用mysql需要安装pam。(open***直接通过mysql,跟通过radius调用mysql主要是在计费统计上有很大区别,认证什么的差不多)
rpm -qa | grep pam
pam_passwdqc-1.0.2-1.2.2
pam-0.99.6.2-3.14.el5
pam_pkcs11-0.5.3-23
pam_krb5-2.2.11-1
pam-devel-0.99.6.2-3.14.el5
pam_smb-1.1.7-7.2.1
pam_ccreds-3-5
(1)、lzo
wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.02.tar.gz
tar zxvf lzo-2.02.tar.gz
cd lzo-2.02
./configure
make
make install
这一部分是支持open***的压缩功能
(2)、安装open***
cd open***-2.0.9
./configure --prefix=/usr/local/open*** --with-lzo-headers=/usr/local/include/lzo \
--with-lzo-lib=/usr/local/lib --with-ssl-headers=/usr/include/openssl \
--with-ssl-lib=/usr/lib
make
make install
注释:以上路径请根据自己系统的配置调整
(3)、生成密匙
cd /usr/local/src/open***-2.0.9
cp -rf ./easy-rsa/ /usr/local/open***/
cd /usr/local/open***/easy-rsa/2.0
source ./vars
./clean-all
./build-ca
./build-key-server server
./build-dh
./build-key cl1
cd keys
/usr/local/open***/sbin/open*** --genkey --secret ta.key
cd /usr/local/open***
mkdir ssl
cp -a ./easy-rsa/keys/2.0/ca.crt ./ssl/
cp -a ./easy-rsa/keys/2.0/dh1024.pem ./ssl/
cp -a ./easy-rsa/keys/2.0/ta.key ./ssl/
cp -a ./easy-rsa/keys/2.0/server.crt ./ssl/
cp -a ./easy-rsa/keys/2.0/server.key ./ssl/
3、安装 RadiusPlugin
(1)、安装
cd /usr/local/src/
wget wget http://www.nongnu.org/radiusplugin/radiusplugin_v2.0b_beta2.tar.gz
tar zxvf radiusplugin_v2.0b_beta2.tar.gz
cd radiusplugin_v2.0b_beta2
make
cp /usr/local/src/radiusplugin_v2.0b_beta2/radiusplugin.so /usr/local/open***/
cp /usr/local/src/radiusplugin_v2.0b_beta2/radiusplugin.cnf /usr/local/open***/
vi /usr/local/open***/radiusplugin.cnf
这里2个文件的位置,是自己定义的,根据这个定义的位置,后面相关配置要设定这里路径的
(2)、配置radiusplusin插件的配置文件radiusplugin.cnf
# The NAS identifier which is sent to the RADIUS server
NAS-Identifier=Open***
# The service type which is sent to the RADIUS server
Service-Type=5
# The framed protocol which is sent to the RADIUS server
Framed-Protocol=1
# The NAS port type which is sent to the RADIUS server
NAS-Port-Type=5
# The NAS IP address which is sent to the RADIUS server
NAS-IP-Address=127.0.0.1
# Path to the Open××× configfile. The plugin searches there for
# client-config-dir PATH (searches for the path)
# status FILE (searches for the file, version must be 1)
# client-cert-not-required (if the option is used or not)
# username-as-common-name (if the option is used or not)
Open×××Config=/usr/local/open***/server.conf
# Support for topology option in Open××× 2.1
# If you don't specify anything, option "net30" (default in Open×××) is used.
# You can only use one of the options at the same time.
# If you use topology option "subnet", fill in the right netmask, e.g. from Open××× option "--server NETWORK NETMASK"
#subnet=255.255.255.0
# If you use topology option "p2p", fill in the right network, e.g. from Open××× option "--server NETWORK NETMASK"
#p2p=10.10.0.1
####################### Ich benutze die Default Option
# Allows the plugin to overwrite the client config in client config file directory,
# default is true
overwriteccfiles=true
# Path to a script for vendor specific attributes.
# Leave it out if you don't use an own script.
# vsascript=/root/workspace/radiusplugin_v2.0.5_beta/vsascript.pl
# Path to the pipe for communication with the vsascript.
# Leave it out if you don't use an own script.
# vsanamedpipe=/tmp/vsapipe
# A radius server definition, there could be more than one.
# The priority of the server depends on the order in this file. The first one has the highest priority.
server
{
# The UDP port for radius accounting.
acctport=1813
# The UDP port for radius authentication.
authport=1812
# The name or ip address of the radius server.
name=127.0.0.1
# How many times should the plugin send the if there is no response?
retry=1
# How long should the plugin wait for a response?
wait=1
# The shared secret.
sharedsecret= testing123
}
注释:这里的sharedsecret= testing123跟radiusd的设置相关,注意/usr/local/etc/raddb/clients.conf中的client 127.0.0.1 的设置,(这个clients.conf是调用radius的客户端配置)
client 127.0.0.1 {
secret = testing123
shortname = localhost
nastype = other
}
同时重要的是要在正式应用的时候 同时修改这2个地方的testing123,这个就是radius的密匙
4、配置open***的服务器设置文件server.conf
cp /usr/local/src/open***-2.0.9/sample-config-files/server.conf /usr/local/open***/server.conf
vi /usr/local/open***/server.conf
注释:注意这里的server.conf要与/usr/local/open***/radiusplugin.cnf中Open×××Config的设置一致
这里的open***服务器端可以有多个配置文件,每一个配置等于开启了一个单独的***服 务,但是要单独设置每个服务器端配置文件./build-key-server ser*** 同时不同的客户端./build-key cl1*** 对应于相应 ser****的unit name,同时客户端要拷贝不同的ser***.crt
port 1194
proto udp
# Which device
dev tun
;fast-io
user nobody
group nogroup
persist-tun
persist-key
server 10.14.0.0 255.255.0.0
management 127.0.0.1 7505
float
username-as-common-name
;client-config-dir ccd
client-cert-not-required
client-to-client
#push "redirect-gateway def1"
push "dhcp-option DNS 172.21.41.15"
ping-timer-rem
keepalive 10 120
# Use compression
comp-lzo
# Strong encryption
tls-server
tls-auth ssl/ta.key 0
dh ssl/dh1024.pem
ca ssl/ca.crt
cert ssl/server.crt
key ssl/server.key
max-clients 200
plugin /usr/local/open***/radiusplugin.so /usr/local/open***/radiusplugin.cnf
verb 3
mute 10
status /var/log/open***/status.log 1
log /var/log/open***/open***.log
mkdir /usr/local/open***/ccd
mkdir /var/log/open***
这里我定义10.14段主要是不想跟别人定义的冲突:
#让客户端发起的所有IP请求都通过OPEN×××服务器
#这一句还是不用的好,没必要全部从***走,一般通过dns把内网的通过这里就可以了
#除非对方本地上网是被限制的,那么可以考虑开放这个配置,所有的通过***上网
push "redirect-gateway def1"
#定义客户端的dns服务器地址,设置本地的服务器内网地址就可以了
push "dhcp-option DNS 172.21.41.15"
注释:(这一部分暂时用不到,就是端到端的服务配置)
关于服务器端内网可以访问客户端内网的设置
# 使服务器子网内机器可以访问客户端子网内机器
# 仅用于路由模式
# 假设:客户端子网网段192.168.1.0
# 首先,在服务器配置文件中添加下面这两行
# client-config-dir ccd
# 和route 192.168.1.0 255.255.255.0
# 然后在服务器端ccd目录下创建一个文件,文件名是客户端的公共名,这里的公共名是客户证书的公共名
# 文件内容是:
# iroute 192.168.1.0 255.255.255.0
;client-config-dir ccd
;route 192.168.1.0 255.255.255.0
ccd目录通常在配置文件目录下面建立,公共名(common name)在生成证书,回答问题时填上的,跟证书的文件名一至.
route 192.168.1.0 255.255.255.0表示在服务器端增加访问客户端的路由(192.168.1.0/24指的是客户端网段)
我现在的配置还暂时用不到这个设置项,以上只是参考,感觉有些特殊的地方还是用的到的!
client-to-client 如果让Client之间可以相互看见,去掉本行的注释掉,否则Client之间无法相互访问
duplicate-cn 是否允许一个User同时登录多次,去掉本行注释后可以使用同一个用户名登录多次
plugin /usr/local/open***/radiusplugin.so /usr/local/open***/radiusplugin.cnf 说明使用的插件,
client-cert-not-required #不请求客户的CA证书
username-as-common-name #使用客户提供的UserName作为Common Name
四、开启radius和open***服务
1、建立open***的shell执行脚本
cp /usr/local/src/open***-2.0.9/sample-scripts/open***.init /etc/init.d/
ln -s /usr/local/open***/sbin/open*** /usr/sbin/open***
vi /etc/init.d/open***.init
work=/usr/local/open***
2、开启 open***服务器进程
/etc/init.d/open***.init start
这个时候要看一下 ifconfig 有没有 tun0设备,如果有就基本ok了!
如果有错误,请看/var/log/messages 和 /var/log/open***/open***.log的信息
如果关闭open***使用 :/etc/init.d/open***.init stop
在测试的时候,由于配置出错,会碰到/etc/init.d/open***.init stop关闭不了,使用killall open***来关闭
3、开启radius服务
这个做到这里容易忘记,我就忘了,还查了一阵子错误
radiusd &
五、windows下client.opvn客户端配置文件:
# Which device
dev tun
persist-key
persist-tun
# Our remote peer
nobind
remote *.*.*.* 1194
#出现用户、密码的认证
auth-user-pass
ns-cert-type server
tls-auth ta.key 1
#对于客户端建立了***连接后,通过***远程走的route设定(这里172.16.0.0 255.248.0.0是所有的内网包括从内部路由走出去的其他公司的内网,可以添加多个网段。)
route 172.16.0.0 255.240.0.0
# Use compression
comp-lzo
# Strong encryption
verb 3
mute 10
六、服务器端的路由和防火墙的调整
把以下的iptables命令放在靠前的规则中
#我这里定义$IPT 是 /sbin/iptables
#对于udp 1813和udp 1812 端口,因为radius是127.0.0.1本地的调用,所以不要另外再开许可
#打开open***连接端口udp 1194
$IPT -A INPUT -p udp -m udp --dport 1194 -j ACCEPT
#许可tun设备的,如果你开的是tap设备进行相应的更改
$IPT -A INPUT -i tun0 -j ACCEPT
$IPT -A OUTPUT -o tun0 -j ACCEPT
$IPT -A FORWARD -i tun0 -j ACCEPT
$IPT -t nat -A POSTROUTING -s 10.14.0.0/24 -o $LOCAL_IFACE -j SNAT --to-source $LOCAL_IP
七、自安装客户端的生成步骤
1、下载客户端制作程序
http://www.open***.se/files/nsis/nsis205.exe
http://www.open***.se/files/install_packages_source/open***_install_source-2.0.9-gui-1.0.3.zip
2、安装nsis205.exe
(1)、生成正确的配置源
在windows下解压缩 open***_install_source-2.0.9-gui-1.0.3.zip
进入open***_install_source-2.0.9-gui-1.0.3/open***/目录下,建立config,
将正确的客户端的配置文件和密匙放到这个目录下(一个配置文件、3个跟密匙有关的文件):
client.o***、 ta.key 、ca.crt、server.crt
注释:
clint.o***就是client.conf!
(2)、编辑生成正确的配置文件
编辑open***_install_source-2.0.9-gui-1.0.3目录下open***-gui.nsi文件
查找 ;File "${HOME}\config\Office.o***"
替换成
File "${HOME}\config\client.o***"
File "${HOME}\config\ca.crt"
File "${HOME}\config\server.crt"
File "${HOME}\config\ta.key"
(3)、生成自动安装程序
运行NSIS Menu 的
compiler -- star MakNsiSW
菜单files--load script
导入open***_install_source-2.0.9-gui-1.0.3/目录下的open***-gui.nsi
导入这个open***-gui.nsi就会在目录open***_install_source-2.0.9-gui-1.0.3下自动生成open***_install_source-2.0.9-gui-1.0.3-install.exe
在客户端运行这个程序就能得到正确配置的客户端!
参考:
http://www.roessner-net.com/×××_RADIUS_MYSQL.howto.txt
http://www.linuxfly.org/read.php?86
http://www.xiaohui.com/dev/server/20070514-install-open***.htm
http://www.xxlinux.com/linux/article/development/database/20060707/2522_2.html
http://blog.chinaunix.net/u/2389/
Ethernet Bridging
译者:温占考(Email: wzkwenzknet),来源:Open×××.net,转载请注明译者和出处及版权信息,并且不能用于商业用途,违者必究。 由于英语水平有限,如有错误,还望指正! 时间: 2006-06-19 22:00 于 沈阳
桥接概述
查看 FAQ 了解路由对比桥接的概述。
以太网桥接实质上是把一个以太网络接口和一个或多个虚拟TAP接口桥接在一个网桥接口上。以太网桥表现为使用软件模拟一个真实的以太网交换机。以太网桥可以理解为一种能够用来连接一个机器上的多个以太网接口(无论是物理的还是虚拟的)使它们共享一个IP子网的软件交换机。
把分布在两个独立网络的一个物理的以太网NIC和一个Open×××所使用的TAP接口桥接起来,这样就可以逻辑上合并两个以太网络,就像它们在一个以太网子网内。
配置桥接
这个例子将指导你配置一个Open×××服务器端的桥接。多个客户将会连接到这个网桥上,并且每个客户机的TAP接口将会分配到一个服务器端LAN网段的IP地址。
下面是两个实现客户IP地址分配的方法:
• 让Open×××使用server-bridge指示来管理其客户的IP地址池,或者
• 在LAN内配置DHCP服务器让其为×××客户分配IP地址。
在这个例子中,我们将使用第一个方法即Open×××服务器管理其客户在LAN子网内的IP地址池,和DHCP服务器使用的地址池分开(如果存在的话)。两种方法在 FAQ item 都有详细描述。
在我们的例子中,我们将使用下面的网桥配置:
设置
网桥启动 参数
取值
以太网络接口
eth
eth0
本地IP地址
ip
192.168.8.4
本地子网掩码
eth_netmask
255.255.255.0
本地广播地址
eth_broadcast
192.168.8.255
×××客户地址池
192.168.8.128 to 192.168.8.254
虚拟网桥接口
br
br0
虚拟TAP接口
tap
tap0
第一步是按照 HOWTO 中的“开始使用×××并且测试其连通性(Starting up the ××× and testing for initial connectivity)”章节。然后,根据你是在Linux或Windows下配置桥接继续配置。
在Linux上配置桥接服务器
首先,确认你已经安装了bridge-utils软件包。
编辑下面的 bridge-start (启动网桥)脚本。根据你要桥接的物理网络接口设置br, tap, eth, eth_ip, eth_netmask, 和 eth_broadcast 参数。确认使用一个内部网络接口并且是连接在一个受防火墙保护的LAN内。你可以使用Linux的ifconfig命令获得网络接口的一些必要的信息来完成bridge-start(启动网桥)参数。
现在就运行bridge-start脚本。脚本将会创建一个永久[译者注:永久意为系统重新启动前永久,默认虚拟接口在Open×××退出后就消失]的tap0网络接口并且已经和以太网接口桥接成功了。
下一步,我们将要编辑 Open××× server configuration file (Open×××服务器端配置文件)来使能桥接配置。
注释掉dev tun这行行并且替换成:
dev tap0
注释掉以server开始的行并且替换成:
server-bridge 192.168.8.4 255.255.255.0 192.168.8.128 192.168.8.254
现在设置Linux防火墙使之允许数据包通过新建的tap0 和 br0接口:
iptables -A INPUT -i tap0 -j ACCEPT
iptables -A INPUT -i br0 -j ACCEPT
iptables -A FORWARD -i br0 -j ACCEPT
Open×××桥接现在能够通过下面顺序来启动和停止:
• 运行 bridge-start
• 运行 open***
• 停止 open***
• 运行 bridge-stop
到目前为止,桥接的配置就完成了,你可以 continue where you left off in the HOWTO (根据HOWTO继续完成剩下部分)。
在Windows XP中配置桥接服务器
这个配置在桥接端需要Windows XP或更高版本系统。据我所知,Windows 2000不支持桥接,然而Windows 2000系统可以是一个桥接网络的客户,而Open×××另一端的桥接是在Linux或Windows XP系统上实现的。
在Windows上安装Open×××时,安装程序将自动创建一个名为“本地连接2”的TAP-Win32适配器。转到控制面版中的网络连接下并且改名为“tap-bridge”。
接下来使用鼠标选择tap-bridge和以太网适配器,点击鼠标右键,并且选择桥接(Bridge Connections)。这样就在控制面板中创建了一个新的桥适配器图标。
在桥适配器的TCP/IP属性里配置IP地址192.168.8.4子网掩码255.255.255.0。
接下来,编辑 Open××× server configuration file (Open×××服务端配置文件) 使能桥接配置。
注释dev tun这行且替换成:
dev tap
dev-node tap-bridge
注释以server开始的行并且替换成:
server-bridge 192.168.8.4 255.255.255.0 192.168.8.128 192.168.8.254
如果你的系统时XP SP2,进入防火墙配置控制面板,并且禁用桥适配器和TAP适配器上的包过滤功能。
到目前为止,桥接的配置就完成了,你可以 continue where you left off in the HOWTO (根据HOWTO继续完成剩下部分)。
配置桥接客户端
在 sample Open××× client configuration (Open×××客户配置)基础上进行配置。注释dev tun的行且替换成:
dev tap
最后,确认客户端的配置文件和服务器端的配置文件是否一致。需要着重注意的是proto (udp or tcp)选项是否一致。同样如果使用了comp-lzo 和 fragment确认客户端和服务器端是否一致。
以太网桥接说明
使用以太网桥接配置时,第一步是构造以太网桥--一种虚拟网络接口是其他网络接口的一个容器,可以是物理的NIC也可以是虚拟的TAP接口。以太网桥接口必须在Open×××启动之前创建。
没有通用的网桥配置方法--每个OS有自己的配置方法(见下面例子)。
网桥接口一旦被创建,并且以太网接口加入到网桥中,Open×××就可以启动了。
• 网桥接口是一种由一个或多个以太网络接口组成的虚拟网络接口,这些以太网络接口可以是物理网络接口或Open×××所使用的虚拟TAP接口。
• 当你配置以太网桥接接口时,你需要手工设置网桥接口的IP地址和子网掩码并且不要在Open×××配置文件中使用ifconfig选项来配置。这是因为与TUN/TAP接口不一样,Open×××程序不能配置网桥接口的IP地址和子网掩码。
• Open×××配置文件应该通过dev选项来指定已经加入网桥TAP接口,而不是指定网桥接口的名字。
• 对于Windows系统,使用dev-node选项来指定已经加入网桥TAP-Win32适配器(dev-node这个名字是网络连接控制面板上显示的名字)。
• 在Linux/BSD/Unix系统中,对于dev tap选项,使用你已经加入网桥的TUN/TAP的序号如dev tap0。
• 如果你的Open×××工作在点对点模式,去掉ifconfig选项,如果你使用的是客户/服务器模式,在服务器端使用server-bridge选项。
• 桥接的时候,你必须手工设置网桥接口的TCP/IP设置。例如在Linux中,可以使用ifconfig命令配置而在Windows XP中可以通过配置网络连接面板中网桥接口的TCP/IP属性来实现(在Windows XP和更高版本的网络连接面板中可以通过鼠标操作来实现桥接)。
• 确定只有桥接的TAP接口和内部以太网络接口是被防火墙保护的。不要把TAP接口和连接互联网的网络接口进行桥接,这样可能存在潜在的安全漏洞。
• local 和 remote 所使用的地址不能是桥接子网内的地址--否则将会出现路由环路。
• 理解以太网桥接很重要的一点就是每个加入网桥的网络接口将会失去原有的配置如IP地址和子网掩码。只有网桥接口的TCP/IP设置有效。
• 手工配置网桥时常见的错误是在为网桥配置IP地址和子网掩码之前把主要的以太网络适配器加入到网桥中。这就导致主要的以太网卡“丢失”了原有的配置,但是所属的网桥接口还没有配置,所以这就造成了以太网络接口的连接就丢失了。
• 在大多数情况下,只是在服务器端配置一个可用的桥接,而不是在客户端配置。这样一来,当客户机连接上服务器后就成为了多宿主系统了,例如:它们仍然拥有原有的以太网接口,但是连接到Open×××服务器的上层连接,它们将会有一个新的TAP接口和服务器端的以太网接口桥接(并且有可能是所有连接到服务器的客户机的TAP接口如果在服务器的配置文件里申明了client-to-client选项)。
说明 – Windows下的以太网桥接
Check out this HOWTO by Adam Pavelec.
Windows Notes 页面有更多关于以太网桥接的说明。
说明 – Linux下的以太网桥接, 配置脚本
这些脚本将处理Linux下的网桥的启动和停止。在Open×××发行包的sample-scripts下可以找到。
sample-scripts/bridge-start
#!/bin/bash
#################################
# Set up Ethernet bridge on Linux
# Requires: bridge-utils
#################################
# Define Bridge Interface
# 定义网桥接口
br="br0"
# Define list of TAP interfaces to be bridged,
# for example tap="tap0 tap1 tap2".
# 定义需要桥接的TAP接口列表,如:
tap="tap0"
# Define physical ethernet interface to be bridged
# with TAP interface(s) above.
# 定义需要和TAP接口桥接的物理接口
eth="eth0"
eth_ip="192.168.8.4"
eth_netmask="255.255.255.0"
eth_broadcast="192.168.8.255"
for t in $tap; do
open*** --mktun --dev $t
done
brctl addbr $br
brctl addif $br $eth
for t in $tap; do
brctl addif $br $t
done
for t in $tap; do
ifconfig $t 0.0.0.0 promisc up
done
ifconfig $eth 0.0.0.0 promisc up
ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast
sample-scripts/bridge-stop
#!/bin/bash
####################################
# Tear Down Ethernet bridge on Linux
####################################
# Define Bridge Interface
br="br0"
# Define list of TAP interfaces to be bridged together
tap="tap0"
ifconfig $br down
brctl delbr $br
for t in $tap; do
open*** --rmtun --dev $t
done
为什么使用TUN模式时,Open×××的"ifconfig-pool"选项使用/30子网(一个客户端占用4个私网IP地址)? 这是为了和Windows下的客户端兼容,由于TAP-Win32的TUN模拟模式的限制,Open×××为每个客户端分配一个/30的子网,如果连接Open×××服务器的都是非Windows客户端,则可以在配置文件中使用ifconfig-pool-linear指令来避免这一行为。 在Open××× 2.0中,Open×××服务端可以在仅有一个tun接口的机器上处理多个客户端。要做到这些,可以将你在服务端上看到的点到点PtP连接想象为操作系统和Open×××间的一个连接。在Open×××内部还需要为每个客户端创建另外一个点到点连接。如果所有的O/S都支持tun接口上的真正的PtP连接,则Open×××服务器使用一个IP地址而每个客户端使用另外一个IP地址是可以实现的。 但是,Windows下的TUN/TAP驱动实现并不支持真正的PtP连接,它是通过一个/30子网来模拟的。所以,首先在Open×××服务器和操作系统之间有一个PtP连接192.168.1.1192.168.1.2. 然后Open×××为每一个连接的客户端分配一个/30的子网,第一个/30子网(除掉服务器使用的)是: 192.168.1.4/30 192.168.1.4 -- 网络地址 192.168.1.5 -- 在Open×××服务端上的虚拟IP地址 192.168.1.6 -- 分配给客户端 192.168.1.7 -- 广播地址 要到达Open×××服务器后网络的其它部分,需要给客户端添加(push)一条路由,使流量通过192.168.1.5路由。因为192.168.1.5是Open×××服务器内部的一个虚拟IP地址,用作路由的一个端点(endpoint),所以Open×××不响应在这一地址上的ping包.而192.168.1.1是服务器操作系统上的一个真实IP地址,所以它会响应ping包。 这的确浪费了一些IP地址,但是这是使配置文件在Open×××所支持的所有操作系统中保持一致的最好方法。 TAP-Win32驱动包括了一个给你分配192.168.1.6 IP地址的DHCP服务器,这就是你看到192.168.1.5作为DHCP服务器地址的原因了。
51.la 专业、免费、强健的访问统计
转载于:https://blog.51cto.com/dadloveu/448624