cb09 [Solved] ipfw - nat problem - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Server & Networking > Firewalls

Firewalls IPFW, PF, IPF (but not limited) related discussion

Reply
 
Thread Tools Display Modes
  #1  
Old February 26th, 2012, 20:20
fuhdan fuhdan is offline
Junior Member
 
Join Date: Feb 2010
Location: Switzerland
Posts: 33
Thanks: 9
Thanked 0 Times in 0 Posts
Default ipfw - nat problem

Hi all,

I have built an ipfw firewall with natd. When I set the firewall type to open and add no fw rules, I can access my web server. When I add my rules, the browser times out. I added 'log in all deny, rules. but there is no log entry. Here's my fw config:

Code:
00005 allow ip from any to any via em1  #em1 = LAN Interface
00010 allow ip from any to any via lo0
00014 divert 8668 ip from any to any in via em0  # em0 Public WAN Interface
00020 check-state

00310 skipto 901 tcp from any to 8.8.8.8 dst-port 53 out via em0 setup keep-state
00310 skipto 901 udp from any to 8.8.8.8 dst-port 53 out via em0 keep-state
00330 skipto 901 tcp from any to any dst-port 25 out via em0 setup keep-state
00340 skipto 901 tcp from any to any dst-port 80 out via em0 setup keep-state
00340 skipto 901 tcp from any to any dst-port 21 out via em0 setup keep-state
00341 skipto 901 tcp from any to any dst-port 443 out via em0 setup keep-state
00350 allow tcp from me to any out via em0 setup uid root keep-state
00360 skipto 901 icmp from any to any out via em0 keep-state
00399 deny log ip from any to any out via em0

00410 deny icmp from any to any in via em0
00415 deny tcp from any to any dst-port 113 in via em0
00420 deny tcp from any to any dst-port 137 in via em0
00421 deny tcp from any to any dst-port 138 in via em0
00422 deny tcp from any to any dst-port 139 in via em0
00423 deny tcp from any to any dst-port 81 in via em0
00430 deny ip from any to any frag in via em0
00432 deny tcp from any to any established in via em0
00440 allow tcp from any to me dst-port 22 in via em0 setup limit src-addr 2
00451 allow tcp from any to any dst-port 80 in via em0 setup limit src-addr 10
00460 allow tcp from any to any dst-port 443 in via em0 setup limit src-addr 10
00499 deny log ip from any to any in via em0
00901 divert 8668 ip from any to any out via em0
00902 allow ip from any to any
00999 deny log ip from any to any
65535 deny ip from any to any
Everytime I add the firewall script with
Code:
/etc/ipfw.rules &
it cuts the ssh session. I also see many entries in the log like:
Code:
Feb 26 18:32:35 fortknox kernel: ipfw: 399 Deny TCP xxx.xxx.xxx.xxx:22 yyy.yyy.yyy.yyy:58753 out via em0
where xxx.xxx.xxx.xxx is my current IP and yyy.yyy.yyy.yyy is the server's IP


Thanks for your help.

Last edited by DutchDaemon; February 26th, 2012 at 22:02. Reason: Proper capitalization: http://en.wikipedia.org/wiki/Capitalization
Reply With Quote
  #2  
Old February 27th, 2012, 08:04
cutter cutter is offline
Junior Member
 
Join Date: Feb 2012
Location: Birdland
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi,
Please clarify, you can't reach the web server from where? From outside, from your local network or from the server itself?
I would suggest that you start troubleshooting your script by building a simplified 5-6 lines script that works and then start adding additional conditions.
Cutter
Reply With Quote
  #3  
Old February 27th, 2012, 09:57
binyo66 binyo66 is offline
Junior Member
 
Join Date: Jul 2011
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Same thing here. If I disable ipfw, then RealVNC run smoothly. Googling it up, I found that using IPFILTER will solve the problem. I think I am going to set up IPFILTER and see if it is solve the problem
Reply With Quote
  #4  
Old February 28th, 2012, 13:32
RusDyr RusDyr is offline
Junior Member
 
Join Date: Nov 2011
Location: St.Petersburg, Russia
Posts: 78
Thanks: 5
Thanked 8 Times in 8 Posts
Default

Bad idea and definitely wrong googling.
Do what cutter said.

Last edited by DutchDaemon; February 29th, 2012 at 01:57.
Reply With Quote
  #5  
Old February 28th, 2012, 22:02
fuhdan fuhdan is offline
Junior Member
 
Join Date: Feb 2010
Location: Switzerland
Posts: 33
Thanks: 9
Thanked 0 Times in 0 Posts
Default solved - ipfw - nat problem

I found the solution:
wrong:
Code:
00451 allow tcp from any to any dst-port 80 in via em0 setup limit src-addr 10
right:
Code:
00451 skipto 901 tcp from any to any dst-port 80 in via em0 setup limit src-addr 10
Then it works fine.

Just to clarify:
I couldn't reach the web server from the internet.

Last edited by phoenix; February 28th, 2012 at 22:49. Reason: Please format your posts!
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
IPFW and nat problem Criosphinx Firewalls 4 December 30th, 2012 17:50
ipfw nat openvpn routing problem leonetix Firewalls 1 August 17th, 2011 03:34
IPFW+NAT+FreeBSD7.3 please help to solve problem rman-86 Firewalls 7 September 22nd, 2010 17:39
IPFW kernel nat problem FreeBSD 8.1 release apanas Firewalls 18 September 18th, 2010 12:54
ipfw nat tablearg --> ipfw nat 0 sandrey Firewalls 0 February 6th, 2009 16:54


All times are GMT +1. The time now is 03:46.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0