Pages

Friday, 15 October 2021

Turn a Linux server to a gateway/router via firewalld

 1 what we have

  • A Linux server with two network interfaces, firewalld and NetworkManager enabled and running.
    • WIFI interface: wlp10s0, IP 192.168.1.71/24, connected to ISP router.
    • Ethernet interface: enp0s25, IP 192.168.168.2/24, connected to home switch.
  • Another computer with one network interface
    • Ethernet interface, IP 192.168.168.100/24, connected to the home switch.
    • The Gateway is set to: 192.168.168.2

2 Steps

# nmcli connection mod enp0s25 connection.zone internal
# nmcli connection mod wlp10s0 connection.zone external

# firewall-cmd --zone external --add-masquerade --permanent
# firewall-cmd --zone internal --set-target=ACCEPT
# firewall-cmd --reload

# sysctl -w net.ipv4.ip_forward=1

To test on the other computer, run:

$ ping 1.1.1.1

3 Tips

The above blue-colored command cost me several hours to find it. 

No comments:

Post a Comment