Skip to main content

Command Palette

Search for a command to run...

Turn your Linux computer into a router the easy way

Published
1 min read

Just run the following commands by adapting your interface names to the situation to turn your Linux computer into a minimal yet fully functional NAT router

$ echo 1 > /proc/sys/net/ipv4/ip_forward
# Edit the following file /etc/sysctl.conf and set the parameter net.ipv4.ip_forward = 1 to make the routing change persistent
$ sudo iptables -t nat -A POSTROUTING -o wlo1 -j MASQUERADE
$ sudo iptables -A FORWARD -i enp2s0 -o wlo1 -m state --state RELATED,ESTABLISHED -j ACCEPT
$ sudo iptables -A FORWARD -i enp2s0 -o wlo1 -j ACCEPT

Don't forget to add the default route pointing towards your computer on the client computers

Resources:

  • https://www.tecmint.com/setup-linux-as-router/

More from this blog

Mensah David Assigbi's personal IT blog

28 posts