Scrivio Interview library
ConceptFoundations6 min read · updated 13 November 2026

A Kafka 4.x cluster must accept connections from applications inside the data centre, from a partner over the internet, and between brokers and controllers.

Explain listeners, advertised listeners, listener.security.protocol.map and the four security protocols, and say which SASL mechanism you would choose for which kind of client.

listeners names the endpoints a node binds, advertised.listeners tells clients which host and port to use for each listener, and listener.security.protocol.map maps each listener name to one of four protocols: PLAINTEXT, SSL, SASL_PLAINTEXT or SASL_SSL. SSL encrypts and with ssl.client.auth=required uses the client certificate as identity, SASL_SSL adds SASL authentication over TLS, and the plaintext variants belong only in development. For mechanisms, SCRAM-SHA-512 suits service accounts, OAUTHBEARER suits central identity with short-lived tokens, GSSAPI suits Kerberos shops, and PLAIN is only for TLS with an external credential check; a partner gets its own SASL_SSL listener or, better, a separate cluster.

Why this question is asked

Listener configuration is where many Kafka setups break on day one. A client connects to the bootstrap address, then times out connecting to a broker address it cannot reach, or authenticates on one port but not another. The confusion comes from three settings that sound alike but do different jobs. Interviewers ask this because getting it right is the foundation of every security discussion that follows. In this answer, we will recap why Kafka needs advertised addresses, go through the three listener settings, compare the four security protocols, see how brokers and controllers pick their own listeners, choose a SASL mechanism per kind of client, and plan access for the partner.

1A Quick Recap: Why Clients Need Advertised Addresses

A Kafka client does not talk to a load balancer that forwards everything. It connects to any bootstrap server, asks for metadata, and receives a list of brokers with their host names and ports. It then connects directly to the broker that leads each partition it needs. So the addresses inside the metadata must be reachable from where the client runs, which may differ from the address the broker binds to inside its own network.

Step throughHow a client finds the brokers
ClientBootstrap brokerPartition leader
connect to kafka.example.com:9094, ask for metadata
brokers: 1 -> b1.example.com:9094, 2 -> b2.example.com:9094
connect to the advertised address of the leader
produce and fetch responses

4 messages in order. Play them, or step through them one at a time.

The second message is built from advertised.listeners for the listener the client connected to.

2Listeners, advertised.listeners and the Protocol Map

Each listener has a name we choose, and the three settings refer to those names. listeners says where the node binds. advertised.listeners says which host and port to give clients that connect through each listener. listener.security.protocol.map says which security protocol each listener uses.

Properties
# broker 1 (server.properties, Kafka 4.x)
process.roles=broker
node.id=1
listeners=INTERNAL://:9092,EXTERNAL://:9094
advertised.listeners=INTERNAL://b1.dc.internal:9092,EXTERNAL://b1.partner.example.com:9094
listener.security.protocol.map=INTERNAL:SASL_SSL,EXTERNAL:SASL_SSL,CONTROLLER:SSL
inter.broker.listener.name=INTERNAL
controller.listener.names=CONTROLLER
controller.quorum.bootstrap.servers=c1.dc.internal:9093,c2.dc.internal:9093,c3.dc.internal:9093
# controller 3001
process.roles=controller
node.id=3001
listeners=CONTROLLER://:9093
controller.listener.names=CONTROLLER
listener.security.protocol.map=CONTROLLER:SSL
ssl.client.auth=required

Notice that a client which connected on port 9094 receives the EXTERNAL addresses of all brokers, while one on port 9092 receives the INTERNAL ones. That is how the same cluster can serve a data centre network and the internet. The names INTERNAL and EXTERNAL are our own; only the protocol map gives them meaning. Older configurations list the controllers with controller.quorum.voters instead of controller.quorum.bootstrap.servers; check what your version uses.

3The Four Security Protocols

The protocol decides two things: whether traffic is encrypted with TLS, and how the client proves who it is. SSL means TLS. On its own it encrypts and lets the client verify the broker's certificate; with ssl.client.auth=required the broker also demands a client certificate, which is mutual TLS, and the certificate's subject becomes the client's identity. SASL_SSL runs SASL authentication, a username and password or a token, inside a TLS connection. The two PLAINTEXT variants do the same without encryption, so passwords and data cross the network readable by anyone on the path; they belong only in local development.

Security protocols
ProtocolEncryptedIdentity from
PLAINTEXTNoNone (ANONYMOUS)
SSLYesClient certificate if ssl.client.auth=required
SASL_PLAINTEXTNoSASL mechanism, credentials readable
SASL_SSLYesSASL mechanism over TLS

4How Brokers and Controllers Talk to Each Other

Brokers replicate data among themselves and talk to the controllers, so they also need to know which listener to use. inter.broker.listener.name picks the listener brokers use to reach each other, and controller.listener.names names the listener the KRaft controllers serve on, which brokers use to reach them. That lets us choose a different security model for internal traffic, for example mutual TLS with certificates from the company PKI for brokers and controllers, while applications authenticate with SASL. Internal traffic is then strongly authenticated without managing passwords for the cluster's own nodes.

5Choosing a SASL Mechanism

SASL is a framework; the mechanism decides what the client actually presents. SCRAM-SHA-512 uses a username and password, but the broker stores only a salted hash in the cluster metadata, created with kafka-configs.sh, and the password never crosses the wire in clear text. It suits service accounts well. OAUTHBEARER uses tokens from an OIDC provider, which gives central identity management and short-lived credentials. GSSAPI is Kerberos and fits companies that already run it. PLAIN sends the password itself, so it is acceptable only over TLS, and by default the broker checks it against passwords written in its JAAS configuration, which does not scale; in practice it is paired with a custom callback that checks an external store.

Text
# create a SCRAM credential for a service account (stored in KRaft metadata)
kafka-configs.sh --bootstrap-server b1.dc.internal:9092 --command-config admin.properties \
--alter --add-config 'SCRAM-SHA-512=[iterations=8192,password=<from secret store>]' \
--entity-type users --entity-name orders-svc
# Completed updating config for user orders-svc.

For our three kinds of traffic, that gives SCRAM-SHA-512 or OAUTHBEARER for applications in the data centre, mutual TLS or SCRAM for brokers and controllers, and for the partner, ideally OAUTHBEARER or a dedicated SCRAM account.

6Letting the Partner In Safely

The partner gets its own listener, EXTERNAL above, with SASL_SSL, its own advertised host names that resolve on the internet, and a firewall that exposes only that port. Its principal gets narrow ACLs on the few topics it needs and a quota so it cannot overload the cluster.

But we should ask whether the partner needs the internal cluster at all. Exposing the cluster that runs the company's internal traffic to the internet widens the attack surface and means one partner incident can affect everyone. Often the better design is a separate small cluster, or replicated topics fed by MirrorMaker 2, so the partner sees only what it needs and the internal cluster stays private.

7Follow-up questions

What happens if advertised.listeners is wrong?

The bootstrap connection succeeds, because it uses the address we configured in the client, but the metadata then hands out addresses the client cannot reach or resolve, so produce and fetch time out. It is the classic symptom of a container or cloud setup where the broker advertises its internal host name.

Can a client use SSL and SASL at the same time?

Yes, that is SASL_SSL: TLS for encryption and SASL for identity. With ssl.client.auth=required on a SASL_SSL listener the broker would also demand a certificate, but the principal still comes from SASL.

Where are SCRAM credentials stored in KRaft?

In the cluster metadata log, managed by the controllers. They are created with kafka-configs.sh, or added when formatting storage for the first bootstrap user.

8Conclusion

In this answer, we saw that listeners binds endpoints, advertised.listeners tells clients where to connect per listener, and listener.security.protocol.map gives each listener a protocol. SSL and SASL_SSL encrypt, mutual TLS uses certificates as identity, and the plaintext variants are for development only. inter.broker.listener.name and controller.listener.names let internal traffic use mutual TLS while applications use SASL. SCRAM-SHA-512 fits service accounts, OAUTHBEARER central identity, GSSAPI Kerberos, and PLAIN only with TLS and an external check, while the partner gets a separate listener with narrow ACLs or a separate cluster.

What to say in the interviewAbout 90 seconds aloud

Open with

Kafka clients bootstrap from one address and then connect directly to partition leaders, so three settings matter. listeners is where the node binds, for example INTERNAL on 9092, EXTERNAL on 9094 and CONTROLLER on 9093. advertised.listeners is what the broker hands out in metadata for each listener, so it must be reachable from the client's network. listener.security.protocol.map maps each name to PLAINTEXT, SSL, SASL_PLAINTEXT or SASL_SSL.

Then, if they want more

SSL encrypts, and with ssl.client.auth required it becomes mutual TLS where the certificate is the identity. SASL_SSL adds SASL authentication over TLS. The plaintext ones send data and credentials unencrypted, so only in development. inter.broker.listener.name and controller.listener.names choose what brokers and controllers use among themselves, so I would run internal traffic on mutual TLS and applications on SASL.

For mechanisms, SCRAM-SHA-512 for service accounts, since the cluster stores only salted hashes in the metadata. OAUTHBEARER if we have an OIDC provider and want central identity and short-lived tokens. GSSAPI where Kerberos exists. PLAIN only over TLS with an external credential check, because by default it reads passwords from the JAAS config.

For the partner I would add a separate SASL_SSL listener with its own advertised address, narrow ACLs and a quota, but I would really prefer a separate cluster or replicated topics so the internal cluster stays private.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Apache Kafka documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain listeners, advertised listeners, listener.security.protocol.map and the four...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-operations/e9d73277a3/