This has been copied from http://area51archives.com/index.php?title=Using_ZNC_with_Tor&action=edit
FYI this can be easily accomplished using
socat by running the following command on the ZNC server, then using
127.0.0.1:4321 as the server in ZNC.
Freenode via TOR:
socat TCP4-LISTEN:4321,fork SOCKS4A:localhost:freenodeok2gncmy.onion:6697,socksport=9050
Assume you just want to use proxy.mycompany.com:8080 as your SOCKS proxy, then the command would be:
socat TCP4-LISTEN:4321,fork SOCKS4A:proxy.mycompany.com:freenodeok2gncmy.onion:6697,socksport=8080
Obviously you can replace the .onion address with another IRC server, or change the port.
Follow the instructions at the tor installation guide.
The installation page gives you an easy walkthrough on compiling and install ZNC for your distribution of choice. This page will have the most up to date version listed quicker than the PPA listed below. For novices, the PPA should serve to be easier to maintain, but comes with a potential lapse of updates. It's your choice.
For Ubuntu-based distros, please refer to the Ubuntu section in the installation guide to install ZNC.
After you have compiled and/or installed znc, you need to configure znc before continuing by running:
At the end of the makeconf screen when it asks if you would like to launch ZNC, select "no."
Tor ships with a SOCKS proxy which is used to tunnel traffic through the Tor network. ZNC doesn't have the option to use SOCKS proxies, that's where ProxyChains comes in. ProxyChains allows you to force an application to use a SOCKS proxy. Luckily, ProxyChains is configured to work with Tor out of the box! You may already have ProxyChains installed.
The recommended way, proxychains v4
With proxychains4, you can specify the .onion address in ZNC directly. With proxychains v3, this was not possible, which we touch on below. This is why proxychains v4 is preferable to v3 when possible. If you do not have proxychains v4 installed already, you can likely install it with:
sudo apt install proxychains-ng
sudo apt install proxychains4
If you are not able to get it via apt, or are not using Ubuntu, you can acquire the source from the GitHub website.
At this point, you can simply run
proxychains znc from the command line. This will start up znc and tunnel its connections via Tor. If you run znc as a system service, then you'll need to edit that config file to launch znc via proxychains.
The old way, .onion resolution
If you only have proxychains v3, you will not be able to immediately connect. It will not work if you attempt to connect to an .onion address directly in ZNC. What we will have to do instead, is map an IP address in the Tor configuration to resolve to the .onion address. This is annoying, but it's really your only shot of making this work. You will want to use an IP range that you will not use, and never plan on using. Let's say you want to connect to 2600net. The .onion address is awwqg2ishrohngue.onion. You would need to open the /etc/tor/torrc file and add at the end of the file:
mapaddress 10.99.99.90 awwqg2ishrohngue.onion
If you were to try to connect to freenode's hidden service (via tor-sasl), you would instead add at the end of the /etc/tor/torrc file:
mapaddress 10.99.99.90 freenodeok2gncmy.onion
Save the file, and restart Tor using:
sudo /etc/init.d/tor restart
...and now you will be able to connect to that .onion address in ZNC by using the server address of 10.99.99.90. For each .onion address you would like to resolve, just add another mapaddress line.