网络配置 a. 设置IP地址和网关 分配IP地址: 在Edge节点上,设置一个适用的私有IP地址,ip addr add 192.168.1.100/24 dev eth ip link set dev eth up 确保这个IP地址在你的网络中是可用的。 设置默认网关: 在Linux上:route -n route add 0.../ via 192.168.1.1 dev eth 在Windows上:iproute route add 0.../ 192.168.1.1 b. 接口配置 设置接口模式和速率: 检查接口状态:ifconfig eth 设置接口为非广播多路访问模式(arp=):ifconfig eth 0... pointmulticast 设置为全双工:ethtool -s 0 ethtool -g 100 100 eth 设置MTU: 检查当前MTU:ip link show eth | grep mtu 设置MTU为150或更高:ip link set dev eth mtu 150 启用ARP: 在Linux上启用ARP:sysctl -a net.ipv4.conf.all.forward_arp=1 sysctl -a net.ipv4.conf.all.accept_arp=1 在Windows上:iparp enable 防火墙配置 a. 允许必要的端口 Linux: 使用iptables:iptables -A INPUT -p tcp --dport 80 -j ACCEPT iptables -A INPUT -p tcp --dport 443 -j ACCEPT iptables -A INPUT -p tcp --dport 22 -j ACCEPT service iptables save service iptables restart 使用firewalld(CentOS/RHEL):firewall-cmd --permanent --add-service=http fir...
网络配置
a. 设置IP地址和网关
-
分配IP地址:
- 在Edge节点上,设置一个适用的私有IP地址,
ip addr add 192.168.1.100/24 dev eth ip link set dev eth up
- 确保这个IP地址在你的网络中是可用的。
- 在Edge节点上,设置一个适用的私有IP地址,
-
设置默认网关:
- 在Linux上:
route -n route add 0.../ via 192.168.1.1 dev eth
- 在Windows上:
iproute route add 0.../ 192.168.1.1
- 在Linux上:
b. 接口配置
-
设置接口模式和速率:
- 检查接口状态:
ifconfig eth
- 设置接口为非广播多路访问模式(arp=):
ifconfig eth 0... pointmulticast
- 设置为全双工:
ethtool -s 0 ethtool -g 100 100 eth
- 检查接口状态:
-
设置MTU:
- 检查当前MTU:
ip link show eth | grep mtu
- 设置MTU为150或更高:
ip link set dev eth mtu 150
- 检查当前MTU:
-
启用ARP:
- 在Linux上启用ARP:
sysctl -a net.ipv4.conf.all.forward_arp=1 sysctl -a net.ipv4.conf.all.accept_arp=1
- 在Windows上:
iparp enable
- 在Linux上启用ARP:
防火墙配置
a. 允许必要的端口
-
Linux:
- 使用iptables:
iptables -A INPUT -p tcp --dport 80 -j ACCEPT iptables -A INPUT -p tcp --dport 443 -j ACCEPT iptables -A INPUT -p tcp --dport 22 -j ACCEPT service iptables save service iptables restart
- 使用firewalld(CentOS/RHEL):
firewall-cmd --permanent --add-service=http firewall-cmd --permanent --add-service=https firewall-cmd --permanent --add-service=ssh firewall-cmd --reload
- 使用iptables:
-
Windows:
- 进入Windows防火墙设置:
- 右键点击“开始”按钮,搜索“防火墙”。
- 展开“允许应用程序通过防火墙”。
- 添加HTTP、HTTPS和SSH到允许列表。
- 进入Windows防火墙设置:
b. 禁用不必要的端口
-
Linux:
iptables -A INPUT -p tcp --dport 1-100 -j DROP
-
Windows:
使用Windows防火墙,设置允许的TCP和UDP端口。
安装和配置Edge网络组件
a. 安装Edge Gateway组件
-
Linux:
- 安装MQTT Broker,如Eclipse Mosquitto:
sudo apt-get install mosquitto sudo mosquitto -h
- 配置Mosquitto:
sudo mosquitto -c mosquitto.conf
- 安装MQTT Broker,如Eclipse Mosquitto:
-
Windows:
- 安装Mosquitto:
wget https://mosquitto.org/downloads/mosquitto-windows/mosquitto-2.1.-windows.zip unzip mosquitto-2.1.-windows.zip
- 启动Mosquitto:
Mosquitto\mosquitto.exe -c mosquitto.conf
- 安装Mosquitto:
b. 配置API端点
-
Linux:
- 配置HTTP服务器:
sudo apt-get install apache2 sudo a2ensite default sudo systemctl start apache2
- 配置API路由:
sudo nano /var/www/html/api/route.py
from flask import Flask, request, jsonify app = Flask(__name__) @app.route('/api/data', 'GET') def getData(): return jsonify({'message': 'Data retrieved'}) if __name__ == '__main__': app.run(debug=True)
- 配置HTTP服务器:
-
Windows:
- 安装IIS:
dism.exe /install Feature:Web-Server
- 配置API路由,例如使用Python:
from flask import Flask, request, jsonify app = Flask(__name__) @app.route('/api/data', 'GET') def getData(): return jsonify({'message': 'Data retrieved'}) if __name__ == '__main__': app.run() - 启动IIS,确保API端点可达。
- 安装IIS:
设备连接配置
a. 设备IP和端口
-
确定设备IP和端口:
设备可能连接到Edge节点的eth接口,IP地址可能是192.168.1.200,端口80或8888。
-
配置设备发送数据的路径:
- 设定设备发送数据的URL,如
http://192.168.1.100:808/api/data。
- 设定设备发送数据的URL,如
b. 身份验证配置
-
Linux:
- 配置Mosquitto:
sudo mosquitto -h # 在配置文件中添加用户: user 1234 password 1234
- 访问Mosquitto:
mosquitto -c mosquitto.conf
- 配置Mosquitto:
-
Windows:
- 配置Mosquitto用户:
Mosquitto\mosquitto.exe -c mosquitto.conf
- 配置Mosquitto用户:
日志和监控配置
a. 日志设置
-
Linux:
- 配置日志级别:
sudo nano /etc/syslog.conf # 添加 *./debug;1 *.info;1 # 保存并退出
- 启用日志:
sudo systemctl start rsyslog
- 配置日志级别:
-
Windows:
- 配置Windows事件日志:
wevtutil.exe -c "Windows Event Tracing Service" -s Application
- 配置Windows事件日志:
b. 监控配置
-
使用Prometheus:
-
安装Prometheus:
sudo apt-get install prometheus
-
配置Prometheus配置文件:
sudo nano /etc/prometheus/prometheus.yml # 添加监控项: global: scrape_interval: 1m scrape_configs: - job: 'prometheus:909' scrape: ['http://localhost:909/metrics'] # 其他监控目标,例如Edge节点 -
启动Prometheus:
sudo systemctl start prometheus
-
-
使用Zabbix:
- 配置Zabbix监控:
# 添加监控项到Zabbix agent
- 启用Zabbix agent:
sudo systemctl start zabbix_agentd
- 配置Zabbix监控:
安全配置
a. 使用HTTPS
-
生成证书:
- 在Linux上:
openssl req -x509 -newkey -days 365 -keyout server.crt -out server.pem
- 在Windows上:
OpenSSL.exe req -x509 -newkey -days 365 -keyout server.crt -out server.pem
- 在Linux上:
-
配置HTTPS:
- 在Linux上,配置Apache:
sudo a2ensite ssl sudo nano /etc/apache2/sites-available/default # 添加 SSLCipherSuite High: All -SSLv2 SSLProtocol all -SSLv3 -TLSv1 +TLSv11 +TLSv13 SSLVerifyDepth 2 SSLEngine Optimal: -strict-require-crl
- 启动SSL:
sudo systemctl restart apache2
- 在Linux上,配置Apache:

下一篇:Edge代理设置指南
相关文章







