Created
March 18, 2025 18:36
-
-
Save nemesifier/eda93447a176527952697c6cdaf0c0f5 to your computer and use it in GitHub Desktop.
OpenWrt redirect to web page with firewall
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
firewall: | |
config rule | |
option name 'Allow DHCP from LAN' | |
option src 'lan' | |
#option dest 'lan' | |
option proto 'udp' | |
option dest_port '67' | |
option target 'ACCEPT' | |
config rule | |
option name 'Allow SSH from LAN' | |
option src 'lan' | |
option proto 'tcp' | |
option dest_port '22' | |
option target 'ACCEPT' | |
config rule | |
option name 'Allow local HTTP' | |
option src 'lan' | |
option proto 'tcp' | |
option dest_port '80' | |
#option dest 'lan' | |
option target 'ACCEPT' | |
config rule | |
option name 'Allow local HTTP on port 8080' | |
option src 'lan' | |
option proto 'tcp' | |
option dest_port '8080' | |
#option dest 'lan' | |
option target 'ACCEPT' | |
config rule | |
option name 'Allow local DNS' | |
option src 'lan' | |
option proto 'any' | |
option dest_port '53' | |
#option dest 'lan' | |
option target 'ACCEPT' | |
config redirect | |
option name 'Redirect HTTP to 8080' | |
option src 'lan' | |
option proto 'tcp' | |
option src_dport '80' | |
option dest_port '8080' | |
option target 'DNAT' | |
config rule 'blackhole' | |
option src 'lan' | |
option target 'DROP' | |
option name 'Block LAN Traffic' | |
dhcp: | |
config dnsmasq 'dnsmasq1' | |
list address '/#/192.168.250.1' | |
uhttpd: | |
config uhttpd 'blackhole' | |
option listen_http '0.0.0e.0:8080' | |
option lua_prefix='/' | |
option lua_handler='/www/captive.lua' | |
/var/captive.lua: | |
function handle_request(env) | |
--uhttpd.send("X-Captive-Portal: true\r\n") | |
uhttpd.send("Status: 200 OK\r\n") | |
uhttpd.send("Content-Type: text/html\r\n\r\n") | |
uhttpd.send("<html><head><title>Redirected</title></head>") | |
uhttpd.send("<body><h1>Welcome to the Captive Portal</h1></body></html>") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment