React with Python Backend on Raspberry Pi Powered by Arduino for Unauthorized VPN and Data Tunneling Access Prevention System for Fiber and ADSL
L. P. Harisha Lakshan Warnakulasuriya(BSc in CS(OUSL)).
Bachelor of Bio Science in Computer Science.
📘 Introduction
Unauthorized VPN and data tunneling attacks are growing threats to both consumer-grade and enterprise-level internet connections. This guide introduces an end-to-end solution built using React (frontend), Python (backend), Raspberry Pi (controller), and Arduino (physical layer monitoring) to secure Fiber and ADSL lines.
🧠 System Architecture Overview
High-Level Components:
Diagram:
+-------------+ +---------------------+ +--------------+
| Arduino Uno | <----> | Raspberry Pi (Python)| <----> | React Web UI |
| (Sensor I/O)| | + Flask Backend | | Dashboard |
+-------------+ +---------------------+ +--------------+
^ |
| v
Fiber/ADSL Internet Traffic
Sensors Packet Monitoring
🧰 Hardware Requirements
🧑💻 Software Requirements
🔐 Network Security Concepts
🧱 Setting up the Raspberry Pi Environment
Raspberry Pi OS Installation
sudo apt update && sudo apt upgrade -y
sudo apt install python3-pip python3-venv git
Flask Setup
python3 -m venv vpn_env
source vpn_env/bin/activate
pip install flask scapy pyserial
🔌 Arduino Integration for Network Monitoring
Arduino Code (Voltage Sensor)
int sensorPin = A0;
void setup() {
Serial.begin(9600);
}
void loop() {
int value = analogRead(sensorPin);
Serial.println(value);
delay(500);
}
Python Code for Reading Arduino Serial
import serial
ser = serial.Serial('/dev/ttyACM0', 9600)
while True:
value = ser.readline().decode('utf-8').strip()
print(f"Sensor Value: {value}")
🧪 Python Backend for VPN/Tunnel Detection
Install Scapy
pip install scapy
Simple Packet Sniffer
from scapy.all import sniff
def detect_vpn(pkt):
if pkt.haslayer("IP") and pkt.haslayer("TCP"):
if pkt["TCP"].dport in [1194, 443] and len(pkt["TCP"].payload) > 1000:
print(f"Possible VPN Tunnel Detected: {pkt.summary()}")
sniff(prn=detect_vpn, store=0)
🌐 React Frontend Setup
Install Node.js & Create App
npx create-react-app vpn-dashboard
cd vpn-dashboard
npm install axios
Sample Dashboard Component (React)
// src/components/Dashboard.js
import React, { useEffect, useState } from 'react';
import axios from 'axios';
function Dashboard() {
const [logs, setLogs] = useState([]);
useEffect(() => {
const interval = setInterval(() => {
axios.get('http://<RASPBERRY_PI_IP>:5000/logs')
.then(res => setLogs(res.data));
}, 2000);
return () => clearInterval(interval);
}, []);
return (
<div>
<h2>Network Alerts</h2>
<ul>{logs.map((log, i) => <li key={i}>{log}</li>)}</ul>
</div>
);
}
export default Dashboard;
📊 Data Logging and Alerting
# backend/logging.py
import datetime
def log_event(event):
with open("logs.txt", "a") as f:
timestamp = datetime.datetime.now().isoformat()
f.write(f"[{timestamp}] {event}\n")
Add to detection function:
log_event("VPN Activity Detected")
Expose logs to React:
from flask import Flask, jsonify
app = Flask(__name__)
@app.route("/logs")
def get_logs():
with open("logs.txt", "r") as f:
return jsonify(f.readlines())
🔌 Schematic Diagram (Text Form)
[Voltage Sensor]---[Arduino UNO]---(USB)---[Raspberry Pi]---[Ethernet]---[Internet Router]
\
---[React Dashboard via Flask API]
Arduino Pins:
USB Cable: Connects Arduino to Pi for serial comms.
🚀 Deploying the System
Backend (Python)
source vpn_env/bin/activate
python3 backend.py
Frontend (React)
cd vpn-dashboard
npm start
✅ Conclusion
With this hybrid setup, we’re securing both the logical (network traffic) and physical (cable tampering) dimensions of network access. This solution is perfect for ISPs, security labs, or industrial users seeking autonomous surveillance of Fiber/ADSL systems.
📎 Future Extensions
📧 Email/SMS Alerting with Twilio
Integrate Twilio in your Python backend to send instant alerts via email or SMS when a VPN/tunneling event or physical tampering is detected.
pip install twilio
from twilio.rest import Client
client = Client(account_sid, auth_token)
client.messages.create(
body="Unauthorized VPN detected!",
from_='+1234567890',
to='+1987654321'
)
🤖 Machine Learning for Packet Behavior Prediction
Utilize scikit-learn or TensorFlow Lite to build a lightweight model on the Raspberry Pi to classify traffic patterns.
pip install scikit-learn
🌐 MQTT Integration for Remote Embedded Control
Use MQTT (via Mosquitto or paho-mqtt) to remotely manage Arduino-triggered events.
pip install paho-mqtt
import paho.mqtt.client as mqtt
client = mqtt.Client()
client.connect("mqtt_broker_ip", 1883, 60)
client.publish("network/alert", "VPN Detected")
📈 Real-time Chart Visualization (Chart.js/Recharts)
Add dynamic graphs to the React dashboard.
npm install chart.js react-chartjs-2
import { Line } from 'react-chartjs-2';
<Line data={chartData} options={options} />
These enhancements will transform your system into a robust, intelligent network monitoring and alerting platform.
🔗 GitHub Repository (Demo)
You can access the complete source code here: 👉
Stay tuned for more real-world AI-powered hardware integration projects!
This Lesson Series are compiled and crafted and teaches by Experienced Software Engineer L.P. Harisha Lakshan Warnakulasuriya.
My Personal Website -: https://www.harishalakshanwarnakulasuriya.com
My Portfolio Website -: https://main.harishacrypto.xyz
My Newsletter Series -: https://newsletter.harishacrypto.xyz
My email address: uniconrprofessionalbay@gmail.com
My GitHub Portfolio : Sponsor @harishalakshan on GitHub Sponsors