Skip to contentSkip to conversation

Need help

DISCUSSION Brad Knorr 2 participants 2 messages Oct 26, 2021

lore
Share & tools
lore

Brad Knorr

author
#0 lore raw

I am new to nft commands. I wish to use the map feature for port forwarding. What I want to achieve is the following

Sftp incoming to port 2222 on the public IP to be port forwarded to private IP on port 22. So what I found in the docs is this.

% nft add map nat foo { type inet_service : ipv4_addr . inet_service \; }

% nft add element nat foo { \

    1100 : 192.168.1.2 . 5061, \
    1101 : 192.168.1.3 . 5061, \
    1400 : 192.168.1.4 . 5061 \
}

% nft add rule nat pre ip protocol tcp dnat ip addr . port to tcp dport map @foo

So when I issue the first command I get the following error:
Error: unqualified mapping data type specified in map definition

When I issue the command: nft add map nat foo { type inet_service :
ipv4_addr \; }

It works just fine. I am at a loss as to why this is happening. The reason I need the mapping is I need to add and remove port forwarding rules easily with a simple command.

Any help would be greatly appreciated.
Brad

#1 lore raw

Hello Brad

Le 26/10/2021 à 06:53, Brad Knorr a écrit :

Quoted 23 lines

I am new to nft commands. I wish to use the map feature for port forwarding. What I want to achieve is the following

Sftp incoming to port 2222 on the public IP to be port forwarded to private IP on port 22. So what I found in the docs is this.

% nft add map nat foo { type inet_service : ipv4_addr . inet_service \; }

% nft add element nat foo { \

     1100 : 192.168.1.2 . 5061, \
     1101 : 192.168.1.3 . 5061, \
     1400 : 192.168.1.4 . 5061 \
}

% nft add rule nat pre ip protocol tcp dnat ip addr . port to tcp dport map @foo

So when I issue the first command I get the following error:
Error: unqualified mapping data type specified in map definition

When I issue the command: nft add map nat foo { type inet_service :
ipv4_addr \; }

Quoted 6 lines

It works just fine. I am at a loss as to why this is happening. The reason I need the mapping is I need to add and remove port forwarding rules easily with a simple command.

Any help would be greatly appreciated.
Brad

% nft add map nat foo { type inet_service : ipv4_addr \; flags interval \; } should do the job

Signature · 1 line
Daniel