I have copied /usr/lib/firewalld/services/ssh.xml and /usr/lib/firewalld/services/telnet.xml to /etc/firewalld
/etc/firewalld/services/ssh.xml is modified to use tcp port 12345
/etc/ssh/ssh_config is modified to use port 12345
/etc/ssh/sshd_config is modified to use port 12345
/etc/firewalld/services/telnet.xml is modified to use port 12346
firewalld has been restarted
I can ssh between computers on port 12345 (that is correct)
I can’t ssh using port 12346 (that is correct)
I cannot telnet on port 12346 (that is incorrect)
But I can telnet on port 12345 (that is incorrect)
That’s not a firewall problem. The “Connection refused” indicates that you do not have a server listening on port 12346. If the firewall were blocking access, you would instead get a timeout.
user@ASUS:~> telnet 192.168.130.123 12345
Trying 192.168.130.123...
Connected to 192.168.130.123.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.6
^]
telnet> quit
Connection closed.
That’s working normally. You have “sshd” listening on port 12345, and “telnet” connected to that port. By design, “telnet” can connect to any port. It won’t be able to run a full telnet session on port 12345, because you do not have a telnet service listening the port. Instead, you have an “sshd” service. So “telnet” gets the banner message, after which you quit. Since the port is open for “ssh”, that allows “telnet” to connect.
It looks to me as if everything is working as you wanted, except that you have not started a telnetd listen process on port 12346.
So in firewalld the telnet xml file is more for the telnet-server service.
So as I don’t need a telnet server, I have nothing to configure the telnet client.
Isn’t it ?
You probably don’t even have “telnet-server” installed. I don’t think it is part of a standard install.
Just think of the telnet program as a useful all-purpose tcp client for testing connections to various ports. That’s how I use it. And there’s nothing to firewall there.