LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-21-2019, 08:04 AM   #1
Dain_Bramage
Member
 
Registered: Mar 2019
Posts: 46

Rep: Reputation: Disabled
NAT with nftables


I have a 192.168.1.0/24 network with a printer on it with with a static IP of 192.168.1.124. I also have a 192.168.3.0/24 VLAN with a linux Mint19.1 computer on it.

I am wanting to use NAT with nftables to NAT all port 631 packets leaving the Mint19.1 computer to 192.168.1.124:631.

The goal is for the Mint19.1 computer to be able to access the printer on the 192.168.1.0/24 network, avoiding the need to have a separate printer.

This is my NAT table:

Code:
table ip nat {
	
	chain pre {
		type nat hook prerouting priority 0; policy accept;
	}

	chain post {
		type nat hook postrouting priority 0; policy accept;
		oif "enp3s0" snat to 192.168.1.124
	}
}

I can NAT all packets leaving the Mint19.1 computer to 192.168.1.124 but I have not been able to figure out how to act specifically on the port 631 packets. Does anyone know the nftables NAT rule to do this?
 
Old 05-24-2019, 02:47 PM   #2
thinknix
Member
 
Registered: Nov 2008
Distribution: Lots!
Posts: 178

Rep: Reputation: 58
I think you're asking the wrong question, you don't need to NAT anything, you just need to allow access from one network to another on a single port.

Is the linux firewall the only host between the two networks? If so the routing should work as-is (both outbound and reply packets will be sent to the default gateway on each host, which should be your firewall), as long as you add an iptables rule to allow the port 631 traffic from your Mint box to the print server. You can verify that the routing works by pinging 192.168.1.124 from the 192.168.3.0/24 network, assuming the ICMP traffic is allowed across the firewall. If you cannot ping across the two networks, we will need to know more about how you have your network setup as far as routers/firewalls and interfaces on them (a simple ascii diagram would help in that case).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help to Convert some iptables NAT rules to nftables netpumber Linux - Server 1 03-08-2017 03:51 PM
NAT and NAT Server behind its own NAT(private network) zeusys Linux - Networking 1 06-08-2011 06:22 PM
LXer: Linux: First Release Of nftables LXer Syndicated Linux News 0 04-02-2010 06:00 AM
LXer: This week at LWN: Nftables: a new packet filtering engine LXer Syndicated Linux News 0 04-09-2009 09:40 AM
LXer: New Kernel Firewall Nftables to Succeed Netfilter LXer Syndicated Linux News 0 03-21-2009 11:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration