Skip to content

Instantly share code, notes, and snippets.

@miladrahimi
Last active November 24, 2024 22:23
Show Gist options
  • Save miladrahimi/b6a1c1f6849ea3b63a0a4af55e1b86cc to your computer and use it in GitHub Desktop.
Save miladrahimi/b6a1c1f6849ea3b63a0a4af55e1b86cc to your computer and use it in GitHub Desktop.
Set Up Debian Server As A Router with NAT
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o ens192 -j MASQUERADE
iptables -A INPUT -i ens224 -j ACCEPT
iptables -A INPUT -i ens192 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -j ACCEPT
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug ens192
iface ens192 inet static
address 78.157.40.163/29
gateway 78.157.40.161
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 8.8.8.8 8.8.4.4
dns-search vm01
# The private network interface
auto ens224
iface ens224 inet static
address 192.168.0.1/24
# gateway 192.168.1.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 8.8.8.8 8.8.4.4
# dns-search vm01
@jult
Copy link

jult commented Aug 11, 2024

but.. we're at nftables now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment