SOHO : Small Office Home Office
Freeware - Opensource software tips, tricks, tweaks & fixes for managing, securing, improving the performance of SOHO Desktop, Laptop, Networks

Wednesday, June 16, 2010

Configure TCP/IP from command line

In order to configure TCP/IP settings such as the IP address, Subnet Mask, Default Gateway, DNS and WINS addresses and many other options you can use Netsh.exe.





Netsh.exe is a command-line scripting utility that allows you to, either locally or remotely, display or modify the network configuration of a computer that is currently running. Netsh.exe also provides a scripting feature that allows you to run a group of commands in batch mode against a specified computer. Netsh.exe can also save a configuration script in a text file for archival purposes or to help you configure other servers.

Netsh.exe is available on Windows 2000, Windows XP and Windows Server 2003.
You can use the Netsh.exe tool to perform the following tasks:
  • Configure interfaces
  • Configure routing protocols
  • Configure filters
  • Configure routes
  • Configure remote access behavior for Windows-based remote access routers that are running the Routing and Remote Access Server (RRAS) Service
  • Display the configuration of a currently running router on any computer
  • Use the scripting feature to run a collection of commands in batch mode against a specified router.

What can we do with Netsh.exe?

With Netsh.exe you can easily view your TCP/IP settings. Type the following command in a Command Prompt window (CMD.EXE):
netsh interface ip show config
With Netsh.exe, you can easily configure your computer's IP address and other TCP/IP related settings. For example:
The following command configures the interface named Local Area Connection with the static IP address 192.168.0.100, the subnet mask of 255.255.255.0, and a default gateway of 192.168.0.1:
netsh interface ip set address name="Local Area Connection" static 192.168.0.100 255.255.255.0 192.168.0.1 1
(The above line is one long line, copy paste it as one line)
Netsh.exe can be also useful in certain scenarios such as when you have a portable computer that needs to be relocated between 2 or more office locations, while still maintaining a specific and static IP address configuration. With Netsh.exe, you can easily save and restore the appropriate network configuration.

First, connect your portable computer to location #1, and then manually configure the required settings (such as the IP address, Subnet Mask, Default Gateway, DNS and WINS addresses).



Now, you need to export your current IP settings to a text file. Use the following command:
netsh -c interface dump > c:'location1.txt
When you reach location #2, do the same thing, only keep the new settings to a different file:
netsh -c interface dump > c:'location2.txt
You can go on with any other location you may need, but we'll keep it simple and only use 2 examples.
Now, whenever you need to quickly import your IP settings and change them between location #1 and location #2, just enter the following command in a Command Prompt window (CMD.EXE):
netsh -f c:'location1.txt
or
netsh -f c:'location2.txt
and so on.
You can also use the global EXEC switch instead of -F:
netsh exec c:'location2.txt
Netsh.exe can also be used to configure your NIC to automatically obtain an IP address from a DHCP server:
netsh interface ip set address "Local Area Connection" dhcp
Would you like to configure DNS and WINS addresses from the Command Prompt? You can. See this example for DNS:
netsh interface ip set dns "Local Area Connection" static 192.168.0.200
and this one for WINS:
netsh interface ip set wins "Local Area Connection" static 192.168.0.200
Or, if you want, you can configure your NIC to dynamically obtain it's DNS settings:
netsh interface ip set dns "Local Area Connection" dhcp
BTW, if you want to set a primary and secondary DNS address, add index=1 and index=2 respectively to the lines of Netsh command.
As you now see, Netsh.exe has many features you might find useful, and that goes beyond saying even without looking into the other valuable options that exist in the command.

Setting up multiple DNS servers from command line with netsh.exe
netsh interface ip set dns local static 188.40.157.19 
netsh interface ip add dns local 208.67.222.222
netsh interface ip add dns local 208.67.220.220
Continue Reading...

Friday, June 11, 2010

Synchronize files with Unison


Synchronize files with Unison


Unison is a file synchronization tool that allows users to maintain two instances of a given file set on two systems up to date and identical. The tool is designed for maximum usability in a variety of contexts and uses protocols like SSH to securely transfer data between folders. Furthermore, the system is designed to be fault tolerant in the case of interruptions and modifications to both "source" and "remote," and aims to always leave both instances of a file or directory tree in a known working state. Unison can be deployed to synchronize files between systems running disparate operating systems, to backup systems, or as part of a content deployment system, among a plethora of other use cases.
Before beginning this guide, we assume you have completed the getting started guide. If you're new to Linux system administration, we recommend considering the guides in our using Linux series, particularly the administration basics guide. If you're simply looking to gain access to your Linode on your local system, you may want to consider deploying a remote file system. Conversely, if you need a more complex backup system, your needs may be better served by an incremental backup system.
These instructions work with the Linode platform. If you don't have a Linode yet, sign up for a Linux VPS and get started today.
Contents
Installing Unison on a Linode
Debian 5 (Lenny)
Ubuntu 9.10 (Karmic)
CentOS 5
Fedora
Arch Linux
Installing Unison on Local Machines
More Information
License

Installing Unison on a Linode 


Debian 5 (Lenny) 

Begin by installing the required software for Unison on the remote machine. Issue the following sequence of commands to ensure that your system's package database is up to date, that all installed packages are up to date, and install Unison:
apt-get update
apt-get upgrade
apt-get install unison
Debian also includes packages for Unison version 2.13 (packaged as unison2.13.16) if you need to use this older version of the software to interact with a specific client. Otherwise, install the more recent version of Unison, packaged as unison.

Ubuntu 9.10 (Karmic) 

Edit the /etc/apt/sources.list to enable to the Universe repositories, so that it resembles the following:
File: /etc/apt/sources.list
## main & restricted repositories
deb http://us.archive.ubuntu.com/ubuntu/ karmic main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic main restricted

deb http://security.ubuntu.com/ubuntu karmic-security main restricted
deb-src http://security.ubuntu.com/ubuntu karmic-security main restricted

## universe repositories
deb http://us.archive.ubuntu.com/ubuntu/ karmic universe
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic universe
deb http://us.archive.ubuntu.com/ubuntu/ karmic-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic-updates universe

deb http://security.ubuntu.com/ubuntu karmic-security universe
deb-src http://security.ubuntu.com/ubuntu karmic-security universe
Finally, issue the following sequence of commands to: ensure that your system's package database is up to date, that all installed packages are up to date, and install Unison:
apt-get update
apt-get upgrade
apt-get install unison

CentOS 5 

The unison packages for CentOS are not included in the base distribution, but are included in the EPEL repositories. Enable the EPEL repository, and ensure that your system is up to date and install unison with the following commands:
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
yum update
yum install unison227
The EPEL repository also includes a package for Unison version 2.13 in the unison213 package. This may be helpful if you need to use this version of the client, otherwise use the more recent version of the software.

Fedora 

On Fedora systems issue the following sequence of commands to ensure that your system is up to date and then install Unison:
yum update
yum install unison

Arch Linux 

Ensure that your local copy of the package database is up to date before installing Unison by issuing the following commands:
pacman -Sy
pacman -S unison

Installing Unison on Local Machines 

In order to function properly, the major and minor version numbers of Unison used by the remote and local system must match. Test the version of Unison that was installed by the package manager on your Linode by issue the following command:
unison -version
Use the information provided by the output of this command to aid in your decision on the appropriate version of your client.
If you are running a Linux-based system on your local machine you can install unison tools using the above procedures. If you're running Debian or Ubuntu systems, you can issue the following command to install a graphical front-end for Unison:
apt-get install unison-gtk
Debian 5 (Lenny) also includes a graphical user interface for Unison version 2.13, packaged as "unison2.13.16-gtk".
If you're running OS X or Windows, download an appropriate Unison client. When successfully installed, provide the client with the resolvable address of the remote server, SSH keys or other authentication credentials, and the absolute paths to the local and remote folders that you want to synchronize. From now on, when you run Unison from the client app, changes to either or both of the specified file systems will be updated and reflected in both instances. Congratulations!

More Information 

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

Continue Reading...

Tuesday, June 1, 2010

Embed photos from picasa web albums

Embed Photos from Picasa Web Albums
Picasa Web Albums is probably the best way to view a photo album online, but did you know you can embed those photos into a site? Next to each photo, Google shows a link that reads "Embed in Blog/MySpace". Check "Hide album link" and copy the HTML code.


You'll notice a link similar to this one:
http://lh6.google.com/image/[username]/[id1]/[id2]/[id3]/s288/name.jpg

Google resizes your photo to 288 pixels width. But that's pretty small, I hear you saying. The nice thing is that you can change the width, but only to fixed values. Here's a list of numbers you can use to replace 288:
72, 144, 200, 320, 400, 512, 576, 640, 720, 800, 912, 1024, 1152, 1280, 1440, 1600.

If you want to place a direct link to a photo, you can use 1600, as this seems to be the biggest value.
Continue Reading...