Created
August 25, 2017 07:54
-
-
Save janhieber/03d124722b89e59815c0d498dc985e2e to your computer and use it in GitHub Desktop.
NAT setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############# on host | |
# set fixed IP (rpi-net) | |
NetworkManager / systemd-networkd ... | |
# enable IPv4 forwarding | |
echo 1 > /proc/sys/net/ipv4/ip_forward | |
echo "net.ipv4.ip_forward=1" > /etc/sysctl.d/ipforward.conf | |
# enable NAT in iptables (rpi-net is target interface) | |
iptables -t nat -A POSTROUTING -o ens33 -j MASQUERADE | |
iptables -A FORWARD -i ens33 -o rpi-net -m state \ | |
--state RELATED,ESTABLISHED -j ACCEPT | |
iptables -A FORWARD -i rpi-net -o ens33 -j ACCEPT | |
iptables-save > /etc/iptables/iptables.rules | |
systemctl enable iptables | |
systemctl start iptables | |
# for DHCP on target use dnsmasq | |
# when using USB ethernet, set fixed dev name | |
/etc/udev/rules.d/10-network.rules: | |
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="00:11:6b:67:e7:db", NAME="rpi-net" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment