凌峰创科服务平台

WiFiDog服务器安装步骤是什么?

WiDog服务器安装是一个涉及多个技术环节的过程,主要用于实现公共无线网络的认证与流量控制,以下是详细的安装步骤与配置说明,适用于基于Linux系统的环境(以Ubuntu为例)。

WiFiDog服务器安装步骤是什么?-图1
(图片来源网络,侵删)

环境准备

在开始安装前,需确保服务器满足以下基本要求:

  1. 操作系统:推荐Ubuntu 18.04/20.04 LTS或CentOS 7/8。
  2. 硬件配置:至少2核CPU、4GB内存、50GB存储空间。
  3. 网络环境:公网IP地址(用于客户端访问),并开放必要端口(如80、443、8080)。
  4. 依赖软件:安装wgetgccmakelibpcre3-dev等编译工具。

通过以下命令更新系统并安装依赖:

sudo apt update && sudo apt upgrade -y
sudo apt install -y wget gcc make libpcre3-dev libssl-dev

安装WiDog服务器

WiDog服务器主要由三部分组成:认证网关(Auth Server)、Portal页面和流量控制模块,以下是具体安装步骤:

安装认证服务器(Auth Server)

认证服务器负责处理用户认证请求和流量统计,推荐使用开源项目wifidog-auth

WiFiDog服务器安装步骤是什么?-图2
(图片来源网络,侵删)
# 下载源码
git clone https://github.com/wifidog/wifidog-auth.git
cd wifidog-auth
# 安装依赖(PHP环境)
sudo apt install -y php php-mysql php-gd php-curl
# 配置数据库
mysql -u root -p
CREATE DATABASE wifidog;
CREATE USER 'wifidoguser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON wifidog.* TO 'wifidoguser'@'localhost';
FLUSH PRIVILEGES;
# 导入数据库结构
mysql -u wifidoguser -p wifidog < database/wifidog.sql
# 修改配置文件
cp config/config.inc.php.dist config/config.inc.php
vim config/config.inc.php

config.inc.php中配置数据库连接信息:

define('DB_USER', 'wifidoguser');
define('DB_PASSWORD', 'your_password');
define('DB_NAME', 'wifidog');
define('DB_HOST', 'localhost');

部署Portal页面

Portal页面是用户登录和认证的界面,可基于HTML/PHP自定义,以下是一个简单示例:

<!DOCTYPE html>
<html>
<head>WiDog认证</title>
</head>
<body>
    <h1>欢迎连接Wi-Fi</h1>
    <form action="http://authserver/login.php" method="post">
        <input type="text" name="username" placeholder="用户名">
        <input type="password" name="password" placeholder="密码">
        <button type="submit">登录</button>
    </form>
</body>
</html>

将Portal页面文件上传至Web服务器(如Nginx/Apache)的根目录,并确保可通过公网访问。

配置流量控制

WiDog通过iptables实现流量控制,安装iptables-persistent保存规则:

WiFiDog服务器安装步骤是什么?-图3
(图片来源网络,侵删)
sudo apt install -y iptables-persistent

添加以下规则限制未认证用户访问:

sudo iptables -A FORWARD -m mac --mac-source ! 00:11:22:33:44:55 -j DROP
sudo iptables-save > /etc/iptables/rules.v4

(注:00:11:22:33:44:55为已认证设备的MAC地址)

配置WiDog网关

  1. 下载并编译WiDog客户端

    wget https://github.com/wifidog/wifidog-gateway/archive/master.zip
    unzip master.zip
    cd wifidog-gateway-master
    ./autogen.sh
    ./configure --with-auth-server=http://authserver
    make && sudo make install
  2. 修改配置文件: 编辑/etc/wifidog.conf,设置认证服务器地址和网关信息:

    GatewayID = MyGateway
    GatewayInterface = eth1
    ExternalInterface = eth0
    AuthServer = {
     Hostname = authserver
     HTTPPort = 80
     Path = /
     LoginScriptPath = /login
     PortalScriptPath = /portal
     MsgScriptPath = /message
     AuthScriptPath = /auth
     PingScriptPath = /ping
     LogoutScriptPath = /logout
    }
  3. 启动WiDog服务

    sudo systemctl start wifidog
    sudo systemctl enable wifidog

常见问题排查

  1. 无法连接认证服务器:检查/etc/wifidog.conf中的AuthServer配置,确保网络可达。
  2. Portal页面加载失败:验证Web服务器端口(80/443)是否开放,防火墙规则是否正确。

相关问答FAQs

Q1: 如何批量导入用户账号?
A1: 可通过MySQL直接导入用户数据,创建CSV文件users.csv,包含usernamepassword字段,然后执行:

LOAD DATA LOCAL INFILE 'users.csv' INTO TABLE users FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (username, password);

Q2: 如何实现认证后的流量限制?
A2: 使用tc(Traffic Control)工具结合WiDog的API接口动态调整带宽,限制单个用户下行速率为1Mbps:

tc qdisc add dev eth0 root handle 1: htb default 30
tc class add dev eth0 parent 1: classid 1:1 htb rate 1mbit
分享:
扫描分享到社交APP
上一篇
下一篇