DNS servers, name servers are typically separate servers not used for other services.
A name server can be used as an authoritative name server for a (practically) unlimited number of domain names.
In for example ISC Bind that would be a named.conf
configuration with as many "zone" stanza's as there are domains:
# named.conf
... other settings:
// We are the primary server for example.com
zone "example.com" {
// this is the primary name server for the zone
type primary;
file "example.com";
// this is the default
notify yes;
// IP addresses of secondary servers allowed to
// transfer example.com from this server
allow-transfer {
192.168.4.14;
192.168.5.53;
};
};
// We are the primary server for example.org
zone "example.org" {
// this is the primary name server for the zone
type primary;
file "example.org";
// this is the default
notify yes;
// IP addresses of secondary servers allowed to
// transfer example.com from this server
allow-transfer {
192.168.4.14;
192.168.5.53;
};
};
and for each domain / zone and associated zone file containing the actual DNS records for that domain.
E.g.
; zone file for example.com
$TTL 2d ; 172800 secs default TTL for zone
$ORIGIN example.com.
@ IN SOA ns1.example.com. hostmaster.example.com. (
2003080800 ; se = serial number
12h ; ref = refresh
15m ; ret = update retry
3w ; ex = expiry
3h ; min = minimum
)
IN NS ns1.example.com.
IN MX 10 mail.example.net.
joe IN A 192.168.254.3
www IN CNAME joe
For web hosting: the mechanism of (name based) virtual hosting is the classical way to host multiple independent websites on a single server. See for example wikipedia article: https://en.wikipedia.org/wiki/Virtual_hosting