LinuxQuestions.org
Review your favorite Linux distribution.
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 08-18-2015, 10:38 PM   #1
raeif
LQ Newbie
 
Registered: Jul 2014
Posts: 11

Rep: Reputation: Disabled
UFW and subnet routing


I have a ubuntu server running as a router between two subnets, 10.10.16.0/24 and 10.10.20.0/24. My goal is to control which traffic crosses subnets using UFW and isolate hosts on the 10.10.16.0 subnet similar to a DMZ. Here's a rough diagram of my set up, I have 3 hosts I'm working with, 1 in the 16.0 subnet and 2 in the 20.0 subnet with my gateways .254 respectively on the router for both subnets:

Code:
                     ROUTER
              --------------------     
(16.10) -->   | 16.254 || 20.254 |    <-- (20.11)
              |  eth0  ||  eth1  |    X-- (20.100)
              --------------------
My specific goal is to allow ssh from 16.10 to 20.11 and vice versa (both Linux) but deny ssh from 20.100 (Windows 8.1) to 16.10. Here are my UFW rules:
Code:
To                         Action      From
--                         ------      ----
10.10.20.254 22/tcp        ALLOW       10.10.20.100
10.10.16.10 22/tcp         ALLOW       10.10.20.11
10.10.20.11 22/tcp         ALLOW       10.10.16.10
10.10.16.0/24              DENY        10.10.20.0/24
10.10.20.0/24              DENY        10.10.16.0/243
I also have enabled IP forwarding in the sysctl.conf file already and added a *nat section to my before.rules:

Code:
#NAT Rules
*nat
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -s 10.10.16.0/24 -o eth0 -j MASQUERADE
-A POSTROUTING -s 10.10.20.0/24 -o eth1 -j MASQUERADE
COMMIT
With IP Masquerading for both subnets configured, I can ssh between all hosts successfully include 20.100 to 16.10, which is not what I want. In this case, UFW doesn't seem to make any difference. This is probably not the right way to do it but its the only way I've found to get it to route between the subnets. I checked the UFW log and it doesn't show where it is allowing the ssh traffic through but it shows where its blocking other passive traffic from 20.100 (something on port 5351??). I have no idea why UFW handling the traffic destined between the subnets.

I'm not an expert when it comes to routing and networking and I'm still learning Linux. I feel I'm missing something basic here so any help is greatly appreciated.
 
Old 08-20-2015, 02:46 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
Do you know deny rule like 10.10.16.0/24 DENY 10.10.20.0/24 is working? Is deny rule like 10.10.16.10 DENY 10.10.20.100 working?
 
Old 08-22-2015, 12:50 PM   #3
raeif
LQ Newbie
 
Registered: Jul 2014
Posts: 11

Original Poster
Rep: Reputation: Disabled
Didn't seem to make a difference. Added the following rule:
Code:
ufw deny from 10.10.20.100 to 10.10.16.10
Was still able to ssh and UFW log didn't show anything. I'm looking into other options also: should I use configure iptables rules directly rather than using UFW? Is UFW intended to manage forwarded traffic as well as traffic destined for and originating from the source machine? For that matter, should they be deny out rules rather than deny in rules or does it make a difference?
 
Old 08-24-2015, 02:25 PM   #4
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,850

Rep: Reputation: 161Reputation: 161
It look like UFW didn't work. You need make sure UFW work in the system.
Yes, iptable is another option.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Routing between two NICS on the same subnet. pwatk Linux - Networking 10 08-06-2010 05:39 AM
Help regarding routing from one subnet to another pauldg123 Linux - Newbie 1 08-07-2008 03:41 PM
routing from one subnet to another NetAX Linux - Networking 2 06-16-2004 08:10 AM
Help with Subnet Routing xatmes Linux - Networking 6 04-26-2004 11:52 PM
routing problem with the same subnet nobody Linux - Newbie 1 10-03-2003 02:23 PM

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

All times are GMT -5. The time now is 02:22 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