I have two computers on the same lanComp A: 192.168.151.19Comp B: 192.1681.151.15 (Static IP address with gateway as <comp A IP address)The setup is like thisInternet <---->  Computer A <-------->  Computer BBoth computers have a single network card. The computer A is connected to the Internet. Computer B is connected to computer A via a usb-ethernet adapter. I have tried to understand iptables and other related questions, but somehow I still not able to configure this correctly.I use the following iptable rules on comp A   iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination 192.168.151.19:443    iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.151.19:80    iptables -t nat -A POSTROUTING -j MASQUERADEOn computer B I use the command sudo ip route add default via 192.168.151.19I ran sysctl -w net.ipv4.ip_forward=1 on both the computers. How can I configure this to give Internet connectivity to computer B. Also, I would like to control internet connectivity to computer B by any firewall rule that I add on computer AEdit: The question is essentially same but with a different network setup. In an earlier question of mine, the computer were not connected to each other physically. Now, One computer is connected to the other via a usb-ethernet adapter and the other computer is connected to the internet
Networking between two computers
networking;iptables;port forwarding;connection sharing