A computer device is provided with a local security mechanism, a personal
firewall, for protecting the computer device from attacks from a foreign
network, in addition to or instead of a firewall in the internal network
which protects the computer when connected to a home network. The
personal firewall is provided with different sets of security rules for
the home network and foreign networks. The personal firewall is arranged
to detect its current location, i.e. determine to which network it is
connected to at each particular moment. The personal firewall activates
one of the given sets of security rules according to the detected current
location of the computer device, i.e. the personal firewall automatically
uses the security rules predefined for the network to which the computer
device is connected at each particular moment. Upon detecting a change in
the location, the personal firewall immediately adapts to use security
rules predefined for the new location.