I’m trying to redirect incoming TCP connections on port 113 to 127.0.0.1:10113 where my ident daemon is running. I have the following configuration:
boot.kernel.sysctl = { "net.ipv4.ip_forward" = true; };
networking = {
domain = "tld";
hostName = "myhost";
networkmanager.enable = false;
nameservers = [ "9.9.9.10" "149.112.112.10" ];
firewall = {
enable = true;
allowedTCPPorts = [ 113 10113 ];
};
useDHCP = false;
nat = {
enable = true;
internalInterfaces = [ "lo" ];
externalInterface = "ens3";
forwardPorts = [
{
sourcePort = 113;
proto = "tcp";
destination = "127.0.0.1:10113";
}
{
sourcePort = 10113;
proto = "tcp";
destination = "127.0.0.1:10113";
}
];
};
};
systemd.network = {
enable = true;
networks = {
"10-default" = {
matchConfig.Name = "ens3";
DHCP = "yes";
linkConfig.RequiredForOnline = "routable";
};
};
};
When connecting on the same machine to localhost, everything is fine:
# nc -zv 127.0.0.1 113
Connection to 127.0.0.1 113 port [tcp/ident] succeeded!
# nc -zv 127.0.0.1 10113
Connection to 127.0.0.1 10113 port [tcp/netiq-endpoint] succeeded!
When connecting on the same machine to the public IP, weird things start to happen:
# nc -zv my.public.ip.address 113
Connection to my.public.ip.address 113 port [tcp/ident] succeeded!
# nc -zv my.public.ip.address 10113
nc: connect to my.public.ip.address port 10113 (tcp) failed: Connection refused
When connecting to the host over the internet:
# nc -zv my.public.ip.address 113
nc: connect to my.public.ip.address port 113 (tcp) failed: Connection refused
# nc -zv my.public.ip.address 10113
(hangs)
I can send ident commands when connecting from the same host, but when connecting remotely I can not. What is wrong here?