Similar to how I can run time command
, I'd like to run a command such as dont_allow_network_access command
. Is this possible?
2 Answers
You can achieve this with lxc. This package contains a tool named lxc-unshare which you can use as follows:
# lxc-unshare -s NETWORK -- su username -c 'ping 127.0.0.1'
This will get you a list of your network devices:
ifconfig -a
If your device you want to diable is eth0
ifconfig eth0 down
and to turn it back on:
ifconfig eth0 up