1. $ cat /usr/bin/startnat.sh
  2. #!/bin/bash
  3. INTERNAL=eth0
  4. EXTERNAL=eth1
  5. echo 1 > /proc/sys/net/ipv4/ip_forward
  6. /sbin/iptables -t nat -A POSTROUTING -o $EXTERNAL -j MASQUERADE
  7. /sbin/iptables -A FORWARD -i $EXTERNAL -o $INTERNAL -m state --state RELATED,ESTABLISHED -j ACCEPT
  8. /sbin/iptables -A FORWARD -i $INTERNAL -o $EXTERNAL -j ACCEPT
  9. --------------------------------------------------------------------------------------------------------------
  10. pi@raspberrypi:~ $ cat /etc/network/interfaces
  11. # interfaces(5) file used by ifup(8) and ifdown(8)
  12. # Please note that this file is written to be used with dhcpcd
  13. # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
  14. # Include files from /etc/network/interfaces.d:
  15. source-directory /etc/network/interfaces.d
  16. post-up /usr/bin/startnat.sh