How can one prevent specific or any wine applications from accessing the internet?
When using certain applications under Windows, they were trying to access the internet from time to time without any obvious reason. I was able to prevent that behaviour with a personal firewall back then. Unfortunately I did not find an application level firewall in Ubuntu up to now. This is especially annoying when I am abroad using data-roaming with my 3G modem.
There's a nice tutorial on blocking any given program from accessing the Internet on the Ubuntu forums.
Steps
iptables rule to prevent that group from accessing the network
Process you don't want to have internet access using
sg
orsudo -g
(execute command as different group ID):It basically involves creating a new group, denying it Internet access, and then running any program you want to restrict as that group ID. So in your case, you would just always run wine using the method described in the tutorial.
Make a group and become a member of it
Now enter an
iptables
rule to block that group from using the internet you can type this on the terminal and hit enterTo make this rule run after each reboot with systemd use
iptables-persistent save
fromiptables-persistent
package.If using rc-local: You can put the rule in
/etc/rc.local
. Make sure the last line in that text file saysexit 0
.Usage example:
You need the
" "
and also type wine before the programs name.EDIT few years later for software not fan of proxy settings & overall a much cleaner & simpler answer :
use bublewrap + unshare to launch your app :
changing proxies / original answer
to add to your wine (or playonlinux virtual drives) registry :
much simpler solution indeed than using groups (& does not prevent pol to connect, just the apps)
credits to http://ootput.wordpress.com/2011/06/06/block-wine-applications-from-the-internet/comment-page-1/
Simply run app as:
The
IPAddressDeny=…
allows to deny access to a set of IPv4 and IPv6 addresses. Special valueany
disables access to all of them for all IP-based protocols, like TCP, UDP, ICMP, SCTP, etc.Example of usage (note: for this demo I had to fix
wine ping
, since it was timing out on me):For the rest of the answer I gonna copy text from my other similar answer on unix.se:
Note: this gonna ask you for a password but the app gets launched as your user. Do not allow this to delude you into thinking that the command needs
sudo
, because that would cause the command to run under root, which hardly was your intention.If you want to not enter the password (after all, you already own your resources, why would you need a password to limit them), you could use
--user
option, however for this to work you gonna need cgroupsv2 support enabled, which right now requires to boot withsystemd.unified_cgroup_hierarchy
kernel parameter.It is not the cleanest solution, but as a temporary solution for PlayOnLinux users, it is easy and fast to setup.
Go to Settings > Internet
Enable
Set a proxy
and enter a website without a proxy e.g.stackoverflow.com
and random user name and password. The programs won't reach the proxy server or the internet.Warning: Be aware, that this will also prevent the install dialog from searching and installing new software!