My workplace has several security policies that run counter to how I would usually set up my laptop. In particular, when connected to the network at work, we are forbidden from having an ssh daemon accepting connections. This generally leads to me getting in trouble at work (when I forget to shut down the sshd) or being unable to access my laptop remotely when it's not at work (when I forget to bring it back up), so I would like to automate this process.Is there a way to automatically change the firewall rules or stop/start the sshd service depending on the SSID of the wifi network I am connected to? I am running CentOS6 if it makes a difference.
Changing network settings depending on SSID
networking;firewall;services;sshd
If you are using the standard dhclient configuration of CentOS 6 then after DHCP has completed it will run a series of post scripts.Of use, here, is the /etc/dhcp/dhclient.d directory.  These scripts will be run after the IP address has been obtained.It would be pretty simple to add a script in here that would look at your wireless setup (iwconfig) and decide whether to stop or start sshd or whether to permit/deny port 22, or anything else you would like.See here for some information on how the scripts need to be set up.