If you're chatting with them via Skype, how can you get their IP address?
Do you need some kind of program or is there a simple, obvious way?
Is it illegal?
For starters, I am not sure if this is illegal or not as this will most likely be dependent on your location.
I personally use the following site to gain the IP Address of a Skype Contact. Go to http://resolveme.org/ and enter the Skype ID of the contact you want the IP Address of.
I have Skype running on a computer, and I can see that the Skype client is periodically exchanging packets with my contacts on Skype. So it is possible to figure out the IP address of your contacts simply by looking on network traffic on your own computer.
I am not aware of any jurisdiction in which it is illegal to look at what is happening on your own computer.
The above method may fail to work if both of you are connected to the Internet through a NAT device. If you want to be sure the packets exchanged with your contacts are going directly, then run the Skype client on a computer with a public IP address.
You will find the Skype client communicating with many different IP addresses, so figuring out which IP corresponds to which contact may require you to correlate periods where they are online with periods where a specific IP is showing up. Otherwise one would have to know a little bit about what is going on inside the Skype client itself.