2

Below is uci config and rules that it produces:

uci add firewall redirect
uci set firewall.@redirect[-1].target=DNAT
uci set firewall.@redirect[-1].proto=tcp   
uci set firewall.@redirect[-1].src=wan
uci set firewall.@redirect[-1].src_dport=80
uci set firewall.@redirect[-1].dest=lan
uci set firewall.@redirect[-1].dest_port=80
uci set firewall.@redirect[-1].dest_ip=10.0.0.10
uci commit firewall
<reboot>
iptables -t nat -A zone_wan_prerouting -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.0.0.10:80
iptables -t nat -D zone_lan_prerouting -p tcp -s 10.0.0.0/255.0.0.0 -d <external_ip_of_router> -m tcp --dport 80 -j DNAT --to-destination 10.0.0.10:80
iptables -t nat -A zone_lan_prerouting -p tcp -s 10.0.0.0/255.0.0.0 -d <external_ip_of_router> -m tcp --dport 80 -j DNAT --to-destination 10.0.0.10:80
iptables -t nat -D zone_lan_postrouting -p tcp -s 10.0.0.0/255.0.0.0 -d 10.0.0.10 -m tcp --dport 80 -j SNAT --to-source 10.0.0.1
iptables -t nat -A zone_lan_postrouting -p tcp -s 10.0.0.0/255.0.0.0 -d 10.0.0.10 -m tcp --dport 80 -j SNAT --to-source 10.0.0.1

But it does not work.

(To get the iptables commands, I used fw3 -4 print before and after uci config, and then diff.)

Redirect starts working only when I manually (first purging the uci config) enter rules #1 and #5 from the above list, with -s 10.0.0.0/255.0.0.0 removed from rule #5.

But the following uci config works:

uci add firewall redirect
uci set firewall.@redirect[-1].target=DNAT
uci set firewall.@redirect[-1].proto=tcp
uci set firewall.@redirect[-1].src=wan
uci set firewall.@redirect[-1].src_dport=5000
uci set firewall.@redirect[-1].dest=lan
uci set firewall.@redirect[-1].dest_port=22
uci set firewall.@redirect[-1].dest_ip=10.0.0.2
uci commit firewall

How can this be explained?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.