带有Web身份validation的Ubuntu Wi-Fi热点

我正在寻找一种解决方案,在我的公司为客人或访客使用,像酒店一样的Wi-Fi热点系统。 我将与用户名和密码共享Wi-Fi连接。 当用户连接到wi-fi系统时,将重定向到他们基于Web的登录页面来连接网站。

我搜索谷歌和这里,但老实说,作为一个关于Linux的菜鸟有很多文章,我有一个大脑爆炸:)大多数人推荐一个现场CD名称是ZoneCD但我在互联网上找不到(他们提供的页面是关于屋顶修复 – http://www.publicip.net/features.php – 文章在这里http://www.linuxplanet.com/linuxplanet/reports/7087/2 )。

另外我发现了一些其他的文章说你可以用开放半径,打开热点附加组件,但说实话,我无法在我的ubuntu上安装。

我真的很困惑,决定在这里问一下,我认为可以在ubuntu bot上做到这一点我们怎么做呢? 以前是否有人这样做过,你能分享一下我们如何做到这一点的信息或文章吗?

第一部分

我遇到了一个Ubuntu热点应用程序,它允许你通过Ubuntu提供wifi,所以我希望这将有助于你正在寻找的那个方面。

文章来源是http://www.webupd8.org/2013/06/how-to-set-up-wireless-hotspot-access.html

要安装ppa,请执行以下命令

sudo add-apt-repository ppa:nilarimogard/webupd8 sudo apt-get update sudo apt-get install ap-hotspot 

现在,在版本14.04中,hostapd无法正常工作,因此以下命令将降级hostapd并使用apt来保存程序包,从而阻止自动升级。

对于64位

 cd /tmp wget http://archive.ubuntu.com/ubuntu/pool/universe/w/wpa/hostapd_1.0-3ubuntu2.1_amd64.deb sudo dpkg -i hostapd*.deb sudo apt-mark hold hostapd 

或者,对于32位

 cd /tmp wget http://archive.ubuntu.com/ubuntu/pool/universe/w/wpa/hostapd_1.0-3ubuntu2.1_i386.deb sudo dpkg -i hostapd*.deb sudo apt-mark hold hostapd 

要启动和配置。 。 。

 sudo ap-hotspot start 

安装后重新配置。 。 。

 sudo ap-hotspot configure 

停止热点。 。 。

 sudo ap-hotspot stop 

并重新启动。 。 。

 sudo ap-hotspot restart 

有关命令列表。 。 。

 ap-hotspot 

第二部分基于Web的身份validation

改编自http://pepperspot.sourceforge.net/index.php?n=Doc.UserDocumentation

我已经更新了一些命令,以符合更多当前使用sudo的做法。

首先安装构建模块

 sudo apt-get install build-essential linux-headers-generic automake subversion libtool 

下载并构建pepperpot源包; 执行以下命令:

 svn co svn://svn.code.sf.net/p/pepperspot/code/trunk pepperspot cd pepperspot autoreconf -f -i ./configure make sudo make install sudo modprobe ipv6 sudo apt-get install radvd iptables libc6-dev quagga apache2 libapache2-mod-php5 libssl-dev freeradius 

1.)激活IPv6

首先,确保在您的内核上激活IPv6。 如果将IPv6编译为模块,请键入:

 sudo modprobe ipv6 

1.1)无状态自动配置

这是/etc/radvd.conf配置文件的示例:

 interface ath0 { AdvSendAdvert on; AdvIntervalOpt on; MinRtrAdvInterval 2; MaxRtrAdvInterval 6; prefix 2001:db8:1::/64 { AdvOnLink on; AdvAutonomous on; AdvRouterAddr on; }; RDNSS 2001:db8:2::1 { AdvRDNSSPreference 8; AdvRDNSSOpen off; AdvRDNSSLifetime 30; }; }; 

用您自己的值替换接口,前缀和RDNSS(DNS服务器信息)行,并使用以下命令启动radvd:

 sudo radvd -C /etc/radvd.conf 

1.2)寻址和路由

强制门户必须将经过身份validation的用户的数据包路由到Internet。 因此系统必须启用IPv6转发。 你可以用以下方式打开它:

 echo "1" | sudo tee /proc/sys/net/ipv6/conf/all/forwarding 

要使此配置保持持久性,可以使用以下命令:

 echo 'net.ipv6.conf.all.forwarding=1' | sudo tee -a /etc/sysctl.conf 

IPv6转发将禁用IPv6自动配置,因此可以使用路由守护进程静态或动态设置网络配置(分配地址和路由)。 对于最后一个程序,请参阅第2节。

如果要使用静态寻址和路由过程,假设eth0是连接到IPv6网络到Internet的接口,请键入以下命令并替换为您自己的值。

在有线接口上分配地址:

 sudo ip -6 addr add 2001:db8:1::1234/64 dev eth0 

添加默认路由配置(替换为路由地址值):

 sudo route -A inet6 add default gw fe80::1:2:3:4 dev eth0 

您可以将此配置持久插入/ etc / network / inteface中的网络配置,如下例所示:

 auto eth0 iface eth0 inet6 static address 2001:db8:1::1234 netmask 64 gateway fe80::1:2:3:4 pre-up modprobe ipv6 # to be sure that ipv6 is enabled before we turn up the interface 

请注意,您不必在连接到“接入点”框的接口上配置地址(如果使用的话,还可以配置无线接口)。

1.3)IPv4

IPv4配置与IPv6大致相同,只是您不需要通告客户端进行网络配置。 PepperSpot集成了一个DHCP模块,用于将IPv4地址归属于远程客户端。 如果无线链接已具有DHCP服务器,或者静态设置了客户端配置,则可以在PepperSpot配置中禁用此模块。 但是,您仍需要配置链接到IPv4网络的接口。

同样,使用以下命令启用IPv4转发:

 echo "1" | sudo tee /proc/sys/net/ipv4/conf/all/forwarding echo 'net.ipv4.ip_forward=1' | sudo tee -a /etc/sysctl.conf 

并配置接口地址和路由(替换为您的参数):

 sudo ip addr add 192.168.0.1/24 dev eth1 sudo route add default gw 192.168.0.254 dev eth1 

您可以使用以下block命令更新/ etc / network / interfaces文件:

 echo 'auto eth1 iface eth1 inet static address 192.168.0.1 netmask 24 gateway 192.168.0.254' | sudo tee /etc/network/interfaces 

1.4)Netfilter支持

PepperSpot将使用一些Netfilter规则来进行客户端和Internet之间的通信。 因此系统必须支持Netfilter。 如果不是这样,请修改内核的配置:

对于IPv4,您需要启用Nat,Mangle和跟踪支持;

对于IPv6,您只需要基本支持。

1.5)备注

所有服务(Radius,Web服务器,PepperSpot,…)都可以安装在提供Wi-Fi访问的系统上(主模式)。 它可以是嵌入式设备,也可以是从头开始配置为接入点的系统。

在这种情况下,您的Wi-Fi卡必须支持主模式。

例如,如果您使用无线接口与madwifi驱动程序,这是一个示例初始化脚本:

 #!/bin/bash # Setting ath0 in Master mode # Replace PepperSpot by your SSID wlanconfig ath0 destroy wlanconfig ath0 create wlandev wifi0 wlanmode ap iwconfig ath0 essid "PepperSpot" ifconfig ath0 up 

2)配置Quagga路由套件

Quagga路由套件实现了一些IPv4和IPv6路由协议。 本节介绍RIPng协议的安装,以允许IPv6路由。 我们假设您有一个委托的IPv6前缀,并且您需要为此前缀路由通信。 如果不是这样,您可以跳过本节。

quagga的配置是通过在/ etc / quagga目录中设置一些配置文件来完成的,但是quagga套件为每个协议集成了一些类似cisco的接口,以允许动态配置并查看路由表等路由信息。

您可以在路由协议配置中放置之前描述的IPv6和IPv4网络配置。 对于您想要的每个协议,请在/ etc / quagga / daemon中启用它。

我们需要启用zebra,因为它是使用其他协议和配置接口所需的主要路由模块。 在我们的例子中,我们只需要添加RIPng:

 # This file tells the quagga package which daemons to start. # # Entries are in the format: =(yes|no|priority) # 0, "no" = disabled # 1, "yes" = highest priority # 2 .. 10 = lower priorities # Read /usr/share/doc/quagga/README.Debian for details. # # Sample configurations for these daemons can be found in # /usr/share/doc/quagga/examples/. # # ATTENTION: # # When activation a daemon at the first time, a config file, even if it is # empty, has to be present *and* be owned by the user and group "quagga", else # the daemon will not be started by /etc/init.d/quagga. The permissions should # be u=rw,g=r,o=. # When using "vtysh" such a config file is also needed. It should be owned by # group "quaggavty" and set to ug=rw,o= though. Check /etc/pam.d/quagga, too. # zebra=yes bgpd=no ospfd=no ospf6d=no ripd=no ripngd=yes isisd=no 

现在我们必须为每个启动的守护进程创建一个配置文件。

/etc/quagga/zebra.conf文件:

 ! ! Zebra configuration saved from vty ! 2008/04/10 12:18:58 ! hostname MobSpot password *********** enable password ************* ! interface ath0 ipv6 nd suppress-ra ! interface eth0 ipv6 address 2001:db8:1::1234/64 ipv6 nd suppress-ra ! interface eth1 ip address 192.168.0.1/24 ipv6 nd suppress-ra ! interface eth2 ipv6 nd suppress-ra ! interface eth3 ipv6 nd suppress-ra ! interface lo ! interface tun0 ipv6 nd suppress-ra ! interface wifi0 ipv6 nd suppress-ra ! ipv6 forwarding ! ! line vty ! 

在此文件中,我们设置链接到服务网络(eth0和eth1)的每个接口的静态配置。

/etc/quagga/ripngd.conf文件:

 ! -*- rip -*- ! ! RIPngd sample configuration file ! ! $Id: ripngd.conf.sample,v 1.1.1.1 2002/12/13 20:15:30 paul Exp $ ! hostname MobSpot password *********** enable password ************ ! ! debug ripng events ! debug ripng packet ! ! router ripng network eth0 redistribute connected redistribute static route 2001:db8:1::/64 ! line vty ! 

在此文件中,我们配置RIPng协议,表明我们能够在eth0接口上路由2001:db8:1 :: / 64前缀的数据包。

对于这两个文件,第一部分将定义配置接口(vty)的密码。 启用密码行表示需要密码才能获得重新配置守护程序的权限。 不要忘记行vty行以启用此配置界面。

对于zebra配置类型:

 sudo telnet 127.0.0.1 zebra 

对于RIPng配置:

 sudo telnet 127.0.0.1 ripngd 

注意:身份validation后(将密码行重新分配到配置文件中),您将获得一个命令行来配置守护程序。 输入“?” 查看可用命令。

要完成,请重新启动quagga守护程序:

 sudo /etc/init.d/quagga restart 

注意:如果需要配置IPv4路由,请将此配置调整为RIP守护程序。

3)Apache配置

PepperSpot需要与安装在同一台机器上的Web服务器通信,以允许客户端继续进行身份validation。 必须为SSL,PHP和CGI配置Web服务器。

以下是Apache2 Web服务器的配置:

生成SSL证书以保证Web服务器的身份:

 sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/key.pem 

第二步是加载Apache2-SSL模块:

 sudo a2enmod ssl 

Web服务器需要可访问的虚拟主机。 使用以下内容创建文件/ etc / apache2 / sites-available / pepperspot (适应所需的配置):

 NameVirtualHost *:443  ServerAdmin webmaster@pepperspot SSLEngine on SSLCertificateFile /etc/apache2/key.pem DocumentRoot /var/www/  Options FollowSymLinks AllowOverride None   Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all # This directive allows us to have apache2s default start page # in /apache2-default/, but still have / go to the right place RedirectMatch ^/$ /apache2-default/  # CGI - We need cgi support to communicate with PepperSpot ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/  AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all  ' 

如果要修改虚拟主机的名称,请不要忘记Apache需要同时监听IPv6和IPv4地址以实现双堆栈模式,并且在IPv4或IPv6接口上需要监听您将选择的单一模式。

添加/etc/apache2/ports.conf以允许使用以下块代码进行HTTPS侦听(如果尚未存在):

 echo ' Listen 443 ' | sudo tee -a /etc/apache2/ports.conf 

最后,加载网站:

 sudo a2ensite pepperspot sudo /etc/init.d/apache2 reload 

4)FreeRadius配置

对于/etc/pepper.conf中的radius服务器地址配置,PepperSpot能够通过IPv4或IPv6协议与Radius服务器通信。 以下是FreeRadius Server的配置。 要获得IPv6支持,您需要FreeRadius> = 2.0的版本。

FreeRadius配置很复杂,下面仅介绍在FreeRadius上启用IPv6支持的基本配置,以及添加一些用户帐户的简便方法。 如果您想要更好的配置,请参阅FreeRadius文档。

4.1)IPv6配置

修改/etc/freeradius/radiusd.conf文件以添加以下部分:

 # For authentication listen { type = auth # ipaddr = * ipv6addr = ::1 port = 0 # interface = eth0 # clients = per_socket_clients } # For accounting listen { type = acct # ipaddr = * ipv6addr = ::1 port = 0 # interface = eth0 # clients = per_socket_clients } 

使用此配置,将字段ipv6addr的:: 1替换为FreeRadius必须侦听的地址。 port = 0表示使用默认的Radius端口。 如果为ipv6addr指定*,FreeRadius将侦听系统上配置的每个IPv6地址。

现在,您需要配置FreeRadius客户端(称为NAS),通常NAS是强制门户。

打开/etc/freeradius/clients.conf文件并添加以下行:

 client ::1 { # here ::1 is the name of the client. Replace with your own value ipv6addr = ::1 secret = testing123 shortname = localhost nastype = other } 

如果PepperSpot和FreeRadius位于不同的框中,则ipv6addr必须替换为PepperSpot和FreeRadius通信的地址。 修改短名称。

要重新启动FreeRadius:

 sudo /etc/init.d/freeradius restart 

4.2)IPv4配置

对于FreeRadius的IPv4配置,将ipv6addr字段替换为ipaddr,并将其填入所需的IPv4地址。

4.3)账户

最后,我们需要在/ etc / freeradius / users中创建帐户:

toto Cleartext-Password:=“totoilsaitpas”

ping6 Cleartext-Password:=“pong6”

重启FreeRadius:

 sudo /etc/init.d/freeradius restart 

5)PepperSpot配置

复制一些配置文件:

 sudo cp doc/pepper.conf /etc/ sudo cp doc/hotspotlogin.cgi /usr/lib/cgi-bin/ sudo chmod +x /usr/lib/cgi-bin/hotspotlogin.cgi 

对于IPv4:

 sudo cp doc/pepper.iptables /etc/ sudo chmod +x /etc/pepper.iptables 

对于IPv6:

 sudo cp doc/pepper.ip6tables /etc/ sudo chmod +x /etc/pepper.ip6tables 

5.2)iptables

修改/etc/pepper.iptables和/或/etc/pepper.ip6tables脚本并调整$ INTIF(连接到接入点或无线接口的接口),$ EXTIF4(连接到IPv4 LAN的接口)和$ EXTIF6(接口)连接到IPv6 LAN)有关配置的值。 请注意,对于双堆栈配置,$ EXTIF4和$ EXTIF6可以具有相同的值。

您可以从pepperspot用户文档中了解其余设置。 http://pepperspot.sourceforge.net/index.php?n=Doc.UserDocumentation只剩下一个配置部分。