user pkalemba tries to test it, but it seems not working in 4.14. are there any requirements (maybe 2nd gmac)?
the following steps must be imho done (first without hnat then enable hnat):
-
make sure all interfaces used have ip-adresses (lan/wan different subnets)
-
setting up NAT: ${ipt} -t nat -A POSTROUTING -o ${if_wan} -j MASQUERADE
-
set up port-forwarding to your client-machine: ${ipt} -t nat -A PREROUTING -p udp --dport $inport -j DNAT --to-destination $dip:$dport
-
enable routing: echo 1 > /proc/sys/net/ipv4/ip_forward
-
test connection between lan-wan
-
loading hnat-kernelmodule via “modprobe mtkhnat”
-
“watch cat /proc/interrupts” and generating traffic like with iperf
is that right?
i currently on the way setup NAT (without HNAT) on wan-interface…added rules on my other router and the pi, my raspberry is accessable from a client (which goes first over my other router). i now try to find a way how to test if NAT really works (i’t not a simple forwarding).
iptables itself says it’s right:
root@bpi-r2:~# iptables -L -v -t nat
...
Chain POSTROUTING (policy ACCEPT 233 packets, 14339 bytes)
pkts bytes target prot opt in out source destination
20 1368 MASQUERADE all -- any wan anywhere anywhere
but tcpdump looks like normal routing:
root@bpi-r2:~# tcpdump -i wan
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wan, link-type EN10MB (Ethernet), capture size 262144 bytes
14:04:26.285393 IP 192.168.50.1 > 192.168.50.2: ICMP echo request, id 2160, seq 1, length 64
14:04:26.286030 IP 192.168.50.2 > 192.168.50.1: ICMP echo reply, id 2160, seq 1, length 64
14:04:27.287170 IP 192.168.50.1 > 192.168.50.2: ICMP echo request, id 2160, seq 2, length 64
14:04:27.287793 IP 192.168.50.2 > 192.168.50.1: ICMP echo reply, id 2160, seq 2, length 64
14:04:28.288186 IP 192.168.50.1 > 192.168.50.2: ICMP echo request, id 2160, seq 3, length 64
14:04:28.288817 IP 192.168.50.2 > 192.168.50.1: ICMP echo reply, id 2160, seq 3, length 64
14:04:31.327195 ARP, Request who-has 192.168.50.1 tell 192.168.50.2, length 46
14:04:31.327220 ARP, Reply 192.168.50.1 is-at 72:56:c3:44:17:77 (oui Unknown), length 28
14:04:31.343694 ARP, Request who-has 192.168.50.2 tell 192.168.50.1, length 28
14:04:31.344246 ARP, Reply 192.168.50.2 is-at b8:27:eb:5f:b8:a2 (oui Unknown), length 46
wan on r2 has the 192.168.50.1, my raspberrypi directly connected to wan has .2, NAT is activated like above:
/sbin/iptables -t nat -A POSTROUTING -o wan -j MASQUERADE