Skip to content
Chandima's Blog
What you think you become.

Primary

  • SAUSECODE.COM
  • Blog
  • .LinkedIn
  • .Github
  • .Hackerrank
  • .About me

Run programs with blocked internet access. [Linux]

Chandima October 25, 2018 how to, kali, learn, linux, tutorial avid internet, block internet, How to block internet access to certain programs on Linux, kali, linux, no internet

Some applications can be really annoying sometimes because they continuously asked us to login at the application startup if you have an active internet connection. In this post i am going to share a method with you to block certain applications from accessing the internet. When you need to run a particular application without internet, all you need to do is running the application by a different command as i described in below.

Step 1: Open the terminal and execute following commands to create and add a new user group called “no-internet”.

groupadd no-internet
useradd -g no-internet username

Step 2: Now let’s create the custom command by creating a new script and put it in /usr/bin/ directory (or create the script file directly in that directory).

nano /usr/bin/no-internet

Now type the following script. Then save and exit.

#!/bin/bash
sg no-internet "$@"

Now let’s make that executable by the following command.

chmod 755 /usr/bin/no-internet

Step 3: Now we should add a rule to iptable to drop the network activity for the newly created group. Since we need to execute this command after a every reboot, we are going to put it in (.profile) script file. You can find it

Open /root/.profile file using a text editor and put the following line at the end. Then, save it.

iptables -I OUTPUT 1 -m owner --gid-owner no-internet -j DROP

Step 4: Now everything is setup. To see a effect, you need to reboot the system or need to execute this command manually.

iptables -I OUTPUT 1 -m owner --gid-owner no-internet -j DROP

Now run a program like this to test. (here i test the firefox browser)

no-internet "firefox"

Now you could run any program using this new command.

PyQT - Try developing GUI applications using Python [PyQt vs Java]PREV
Whatsapp Sticker Update [Sinhala Sticker Pack]NEXT

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary

Search the blog!

Recent Posts

  • Familiarize with these tools before going to Industry May 8, 2021
  • How to let the scripts run in the background [ssh] June 6, 2020
  • NoSQL vs SQL Databases in a Nutshell June 5, 2020
  • SSH to a host through multiple jump hosts. [Linux] April 30, 2019
  • GNU – Octave [matlab equivalent for linux] – This is how you can install packages January 22, 2019

Categories

  • android (11)
  • applications (2)
  • apps (4)
  • arduino (2)
  • avr (1)
  • blog-android (2)
  • blog-arduino (1)
  • computer science (1)
  • database (1)
  • embedded (1)
  • emui (1)
  • games (1)
  • home made (2)
  • Honor 3c (6)
  • how to (15)
  • huawei (6)
  • java (4)
  • kali (7)
  • kitkat (1)
  • learn (10)
  • linux (11)
  • networking (6)
  • octave (1)
  • PC Apps (1)
  • pi4j (1)
  • programming (3)
  • pyqt (1)
  • python (2)
  • raspberry pi (1)
  • remote controlled (1)
  • Server (3)
  • tech (4)
  • tutorial (8)
  • Verilog (1)
  • windows (6)

Tags

2018 aero plane android Android 4.4.2 android app player android apps on windows class cross-platform file honor 3c honor 3c custom unicode honor 3c sinhala how how to how to install how to install custom unicode huawei honor 3c install custom font in honor 3c install custom unicode install unicode interfaces java kali language linux network opengl programming pyqt python remote run scripts server sinhala sinhala app sinhala for huawei sinhala installer sinhala unicode sinhala unicode for honor 3c sinhala unicode installer sinhala unicodes Sri Lanka ssh to

Archives

  • May 2021
  • June 2020
  • April 2019
  • January 2019
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • April 2018
  • March 2018
  • October 2017
  • February 2017
  • June 2016
  • July 2015
  • January 2015
  • December 2014
  • November 2014

"I hear and I forget, I see and I remember, I do and I understand." ~ Confucius

© Copyright 2020 SAUSECODE LABS | Chandima Samarasinghe