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