A user mask looks like: nickname!ident@[ip]/[host]

The Ban command is: /mode #channel +b [mask] or if you’re using mIRC, you may use: /ban #channel [mask]

If you want to set a ban thru X, the syntax is: /msg X ban <#channel> <nick|*!*user@*.host> [duration] [level] [reason]</nick|*!*user@*.host>

To ban a nickname, use a mask like this: nickname!*@*
To ban an ident, use a mask like this: *!ident@*
To ban an ip/host, use a mask like this: *!*@[ip]/[host]

Remark: * replaces any number of characters, ? replaces a single character.

Common examples:

I want to ban all users having IP address starting with 81 in achannel.
You have to place a ban on mask: *!*@81.*

I want to ban all users having IP address ending with 121 in a channel.
The ban has to be placed on mask: *!*@*.121

I want to ban all users having their nickname starting with “Alice” in a channel.
Ban mask: Alice*!*@*

I want to ban all users who are not idented [having “~” in front of their ident] in a channel.
Ban mask is: *!~*@*

I want to ban all users having their identds starting with two random characters in a channel. e.g.: Alice!~76me@12.13.14.15
Place ban on mask: *!~??me@*

I want to ban all persons having in their hosts “adsl” in a channel. e.g.: kjempen!~something@12-13-14.15.adsl.no
Set ban on mask: *!*@*.adsl.*

NOTE Above examples are just for information, and some of them may ban a wide range of users use them carefully.