Forum Navigation
You need to log in to create posts and topics.

Disable outgoing / incoming traffic on Ubuntu


User wants to disable internet access and only leave local network for Ubuntu (or any other linux system)


disable the internet using route del command

IP=$(/sbin/ip route | awk ‘/default/ { print $3 }’)
sudo /sbin/route del default gw “$IP”
echo “$IP” >~/tmp/gw.txt

file will be saved to /tmp/gw.txt to restore the internet connection

cat /tmp/gw.txt
route add default gw <IP address> <NETWORK INTERFACE>


Please change back to Apostrophes and backticks this is forum issue or using the attached script

Uploaded files:

Another option if route del is not possible ( for example ansible fails if no route on some playbooks )

add route to your default network

route add default gw <YOUR IP ADDR> <INTERFACE>


route add default gw ens192