Dns /

Configuring unique vhosts

IRC users often ask for custom vhosts.

How IRC servers check vhosts

When an IRC client first connects to an IRC server, the server will take your IP address and perform a rDNS/reverse lookup. For example, suppose your IP address is 192.168.0.1. To perform a reverse lookup, run:

$ dig -x 192.168.0.1

;; ANSWER SECTION:
1.0.168.19.in-addr.arpa. 60 IN      PTR     example.ircnow.org.

This means that the IP address 192.168.0.1 is pointed to by the domain example.ircnow.org. Now, the IRC client will perform forward DNS resolution, which you can perform yourself by running:

$ dig example.ircnow.org

;; ANSWER SECTION:
example.ircnow.org.             3600    IN      A       192.168.0.1

Notice how the reverse and forward DNS lookups both match and confirm one another. When this happens, anyone that connects from this IPv4 address will have the vhost example.ircnow.org. So, if you logged in with nickname john and ident brown, you would have the following hostmask: john!brown@example.ircnow.org.

IPv6 to the Rescue

Notice however that a single IP address can only have one possible vhost. Even if you have multiple domains pointing to the same IP address, each IP address can only have a single rDNS entry associated with it. In other words, when you run $ dig -x 192.168.0.1, you only get one possible answer.

If we only had IPv4 addresses, each IPv4 address can only have one possible vhost. Since the world is running out of IPv4 addresses, it would cost a lot of money to assign unique vhosts using IPv4 addresses only.

This is why we rely upon IPv6 addresses to provide unique vhosts. Normally, the ISP will provide an entire /64 or /48 subnet of IPv6 addresses for each server instead of a single IPv4 address.

Now you can assign vhosts to your heart's content. All you need is one AAAA record for each hostname and to configure the rDNS entry for the IPv6 address.

For example, suppose you configure cooldude.ircnow.org to point to 2001:db8::c001:d00d, and you configure the rDNS of 2001:db8::c001:d00d to point to cooldude.ircnow.org. Then, when you bind to the IPv6 address 2001:db8::c001:d00d to connect to an IRC network which supports IPv6 connections, the IPv6 server will give you the vhost cooldude.ircnow.org.

Binding to an IP address

When you use a bouncer (such as znc or psybnc), you tell the bouncer to set the bindhost of a user to a specific IPv6 address or hostname. That way, the bouncer will use that IP address to connect. If you want a custom vhost, set it to the hostname or IPv6 address that you want to give to the user. And remember -- both the forward and reverse DNS must be configured properly!

When creating DNS records, I recommend creating both an A and AAAA record for each hostname. This will provide a fallback for networks that only support either IPv4 or IPv6. For example, cooldude.ircnow.org could have both an A record of 192.168.0.1 and an AAAA record of 2001:db8::c001:d00d. That way, when the bouncer binds to the hostname cooldude.ircnow.org, it can choose the IPv6 address if the IRC network supports IPv6, and it can choose IPv4 if the IRC network only supports IPv4.