Hi
I am testing port forwarding on Beaglebone Black
The test environment was configured as follows
NAT and port forwarding are set in each Beaglebone Black.
I installed TCP Client on Laptop PC1 and TCP Server on Laptop PC2
I ran TCP Server on Laptop PC2 and created the socket with port number 10000.
I ran TCP Client on Laptop PC1 and opened socket (IP 223.171.58.99:10000) to connect to TCP server
TCP Client was unable to connect to the TCP Server.
A TCP Client on a desktop in the wired network without using the LTE network were connected to the TCP server.
I don’t know why TCP Client on the Laptop PC1 was unable to connect to the TCP Server.
Could you check if there is a problem with my NAT and port forwarding setting in the shell script below
#!/bin/bash
echo "set NAT ------------------------------------"
eth0_ip=$(ip -4 -o addr show eth0 | awk '{print $4}' | cut -d "/" -f 1)
wwan0_ip=$(ip -4 -o addr show wwan0 | awk '{print $4}' | cut -d "/" -f 1)
route add default gw ${wwan0_ip}
route del -net default gw ${eth0_ip} netmask 0.0.0.0 dev eth0
route del -net 8.8.8.8 gw ${eth0_ip} netmask 255.255.255.255 dev eth0
sysctl net.ipv4.ip_forward=1
iptables -A FORWARD -o eth0 -j ACCEPT
iptables -A FORWARD -o wwan0 -j ACCEPT
iptables -t nat -A POSTROUTING -o wwan0 -j MASQUERADE
echo "set port forwarding -----------------------"
fwd_in_port="10000"
fwd_to_port="10000"
fwd_ip="192.168.10.10"
iptables -t nat -A PREROUTING -p tcp -i wwan0 --dport ${fwd_in_port} -j DNAT --to-destination ${fwd_ip}:${fwd_to_port}
iptables -A FORWARD -p tcp -d ${fwd_ip} --dport ${fwd_to_port} -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
Please help me.
Regards.