foxoman
@foxoman
Tech Addict, Ubuntu Gnu/Linux Fan, Nim/C++ Developer
Yes, you can block applications from accessing the internet on Linux using a few different methods. One popular method is to use the Uncomplicated Firewall (UFW) or the more advanced tool iptables. Both of these tools can help you create rules to block specific applications from accessing the internet. 1- Using UFW: UFW is a user-friendly front-end for managing iptables firewall rules. It’s easier to use and configure compared to iptables. To use UFW, first, make sure it’s installed on your system: sudo apt install ufw To block a specific application from accessing the internet, you can create a rule based on the application’s port number or executable path. For example, if you want to block an application that uses port 12345, you can run: sudo ufw deny out to any proto tcp port 12345 sudo ufw deny out to any proto udp port 12345 2- Using iptables: iptables is a powerful command-line tool for configuring Linux kernel firewall rules. It can be more challenging to use, but it also provides more advanced options. To block a specific application from accessing the internet, you can create a rule based on the application’s user or group ID. First, find the user or group ID of the application you want to block. You can use the id command to find the user ID and the getent command to find the group ID. For example: id -u username getent group groupname Once you have the user or group ID, create an iptables rule to block the application’s outgoing traffic. Replace UID with the user ID or GID with the group ID: sudo iptables -A OUTPUT -m owner --uid-owner UID -j DROP Or for group ID: sudo iptables -A OUTPUT -m owner --gid-owner GID -j DROP Remember to replace “UID” and “GID” with the actual user or group ID. Keep in mind that these changes will be lost after a system reboot. To make the rules persistent, you can use the iptables-persistent package: sudo apt-get install iptables-persistent During installation, you’ll be prompted to save the current iptables rules. Confirm to save the rules, and they will be automatically applied after every reboot. Both methods above allow you to block specific applications from accessing the internet on Linux, just like a Windows firewall.
Dear Kind Followers, As the admin of my instance has upgraded to a new version, we have lost our old profile, so you are welcome to follow me back and allow me to follow you again 😞