Hi! I've created a program just to fix this. The thread I originally posted it in is here .
To use it, first install libgtk2-perl by finding it in synaptic or typing the following in a terminal:
Following that, copy my program into a text file on your hard drive, preferably calling it something that ends in a .pl. Make sure you make it executable (This can be done by right-clicking and going to properties)
sudo apt-get install libgtk2-perl
The brunt of the program happens in the last few lines. It executes a simple bash command copying a file onto the current hosts file using sudo privileges. To fix it for your uses, create the two seperate hosts files you wish to use, and replace /home/adam/Scripts/GTK2/hosts.remote with the path to the one you want to use when away from home, and /home/adam/Scripts/GTK2/hosts.local to the path to the hosts file you wish to use when you are at home.
#copy after this line... those numbers shouldn't be here. Glitch with ubuntuforums, I guess
# by Adam
use Gtk2 '-init';
use Glib qw/TRUE FALSE/;
my $main = Gtk2::Window->new('toplevel');
$main ->set_title('Change Hosts');
$main ->signal_connect(delete_event => \&delete_event);
$main ->set_border_width(15); #this is like CSS' padding, not border
my $box1 = Gtk2::VBox->new(FALSE, 0); #I don't know what these arguments do
my $button1 = Gtk2::Button->new("I'm home");
$button1->signal_connect(clicked => \&host_local);
$box1 -> pack_start($button1, TRUE, TRUE, 0); #what are these arguments?
$button1->show; #this tells Gtk that our button preps are done. Cool.
$button1 = Gtk2::Button->new("I'm not home"); #NEW POINTER, SAME VARIABLE
$button1->signal_connect(clicked => \&host_remote);
$box1 -> pack_start($button1, TRUE, TRUE, 0);
$box1->show; #Box is done being composed. Send to higher level to get rendered.
$main->show; #show the window! :D
0; #frig I keep forgetting this
exec ("gksudo cp /home/adam/Scripts/GTK2/hosts.remote /etc/hosts") || die "Cannot change hosts file: $!\n";
#THIS IS THE FIRST LINE YOU NEED TO CHANGE
exec ("gksudo cp /home/adam/Scripts/GTK2/hosts.local /etc/hosts") || die "Cannot change hosts file: $!\n";
# THIS IS THE SECOND LINE YOU NEED TO CHANGE
Now, for security reasons, you shouldn't keep any of these files in your home folder or writable by anyone except root. If you need help with that... let me know.