I have tried using nc to chat and transfer files over my local network. However, I am having trouble doing it over internet (with my friend). While doing it locally, i would be using ifconfig to view my ip address. I see only one ipv4 address. I am pretty sure this address cannot be used to connect to my friend, as I have tried. Is it their public ip address we have to use in order to establish a connection? If yes, I've tried that too. My main problem is to find out which ip address to use for connection over internet. BTW I am listening while my friend is connecting to my open port.
Chat with friend using netcat
netcat;ip address
The IP address you see using ifconfig is your IP address for your local network only. It is a private address (192.168, right?) and can not be used to communicate over the internet. Your router performs Network Address Translation to convey data between sites you visit and your computer. What you and your friend would have to do is set up port forwarding between your modem/router/etc to your respective computers, both of which are running netcat. 