#!/bin/sh . /etc/functions.sh WAN=$(nvram get wan_ifname) LAN=$(nvram get lan_ifname) # Flush rules iptables -F input_rule iptables -F output_rule iptables -F forwarding_rule iptables -t nat -F prerouting_rule iptables -t nat -F postrouting_rule ### Logging #iptables -A forwarding_rule -i $LAN -j LOG --log-prefix "IN $LAN: " ## Server traffic # HTTP iptables -t nat -A prerouting_rule -i $WAN -p tcp --dport 80 -j DNAT --to 192.168.1.5:80 iptables -A forwarding_rule -i $WAN -p tcp --dport 80 -d 192.168.1.5 -j ACCEPT iptables -t nat -A prerouting_rule -i $WAN -p udp --dport 80 -j DNAT --to 192.168.1.5:80 iptables -A forwarding_rule -i $WAN -p udp --dport 80 -d 192.168.1.5 -j ACCEPT # SMTP iptables -t nat -A prerouting_rule -i $WAN -p tcp --dport 25 -j DNAT --to 192.168.1.5:25 iptables -A forwarding_rule -i $WAN -p tcp --dport 25 -d 192.168.1.5 -j ACCEPT iptables -t nat -A prerouting_rule -i $LAN -p tcp --dport 25 -j DNAT --to 192.168.1.5:25 iptables -A forwarding_rule -i $WAN -p tcp --dport 25 -d 192.168.1.5 -j ACCEPT # SSH iptables -t nat -A prerouting_rule -i $WAN -p tcp --dport 22 -j DNAT --to 192.168.1.5:22 iptables -A forwarding_rule -i $WAN -p tcp --dport 22 -d 192.168.1.5 -j ACCEPT