본문 바로가기

지식/Network

freebsd로 방화벽 만들기 자료 모음

FreeBSD로 라우터를 구성할려고 하고 있습니다.
FreeBSD에서 IP forwarding을 enable 시키는 방법을 알려 주세요.

/etc/rc.local (인가?) 화일을 보시면 IP Forwarding 부분이 Options
부분에 있습니다. 그 부분을 체크해주시면 됩니다.

FreeBSD로 라우터를 구현할 경우, 일단 2개 이상의 네트웍 카드를
인식시켜 주어야 합니다. 저 같은 경우엔 해당 카드의 I/O address와
IRQ 번호를 알고 난 후 이를 직접 커널 컴파일 화일에 기입해 주고
커널을 컴파일해서 또 다른 네트웍 카드를 인식시켜 주었었습니다.
(당연한 얘기겠지만 PnP 모드는 없애 주어야 하구요..)

/etc/rc.conf에서
gateway_enable="YES"

----------------------------------------------------------------------

 ohsy:  내부 네트웍에서 외부로 나가는 것은 되는데, 내부 네트웍에 있는 pc 한대를 webserver로
 ohsy:  활용하려고 하는데 잘 안되네요.
 ohsy: 
 ohsy:  아래의 내용은 rc.conf에 설정되어있는  양식입니다.
 ohsy:  보시고 어디가 잘 못되어있는지 알려주시기 바랍니다.
 ohsy:  제가 원하는 것은 외부에서 211.117.27.194 로 오면 192.168.1.2로 forwarding 시키는 것입니다.
 ohsy:  고수님들의 조언을 기다리겠습니다.
 ohsy:   
 ohsy:  # -- added by woo
 ohsy:  firewall_enable="YES"
 ohsy:  firewall_type="OPEN"
 ohsy:  natd_enable="YES"
 ohsy:  natd_interface="xl1"
 ohsy:  natd_flags="-redirect_port tcp 192.168.1.2:80 80"
 ohsy: 

옵션에 이상이 없어 보입니다만..

여하튼..  211.117.27.194 로 오는것은 무조껀 192.168.1.2 로 보내려면
redirect_address 192.168.1.2 211.117.27.194 를 하시지요..


 
내부 네트웍에서 외부로 나가는 것은 되는데, 내부 네트웍에 있는 pc 한대를 webserver로
활용하려고 하는데 잘 안되네요.
 
아래의 내용은 rc.conf에 설정되어있는  양식입니다.
보시고 어디가 잘 못되어있는지 알려주시기 바랍니다.
제가 원하는 것은 외부에서 211.117.27.194(공인ip)로 오면
192.168.1.2(내부ip)로 forwarding 시키는 것입니다.
고수님들의 조언을 기다리겠습니다.
 
linux_enable="YES"
moused_enable="YES"
gateway_enable="YES"
network_interfaces="xl1 xl0 lo0"
ifconfig_xl0="inet 192.168.1.1  netmask 255.255.255.0"
ifconfig_xl1="inet 211.117.27.194  netmask 255.255.255.192"
ifconfig_xl1:1="inet 211.117.27.195  netmask 255.255.255.192"
defaultrouter="211.117.27.193"
router_enable="NO"
 
firewall_enable="YES"
firewall_type="OPEN"
natd_enable="YES"
natd_interface="xl1"
natd_flags="-redirect_port tcp 192.168.1.2:80 80"


저번에도 답변드렸던 같은데요 -.-

divert xl0 까지는 좋습니다. xl0 으로 들어온것은 natd 의 설정대로 되겠죠.

그러나 , firewall 로 막혀 있는데 이게 제대로 동작할까요.? -.-a

00100 번에 rl0 이 왜 들어간거죠.? 이것을 xl0 으로 적어주시길..



%ifconfig rl0(내부와 연결된 랜카드)
rl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
       inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
       ether 00:e0:29:65:5c:9a
       media: autoselect
       supported media: autoselect 100baseTX <full-duplex> 100baseTX <half-dupl
ex> 100baseTX 10baseT/UTP <full-duplex> 10baseT/UTP 10baseT/UTP <half-duplex>

ifconfig xl0(인터넷과연결된카드)
xl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
       inet 211.xx.xx.xx netmask 0xffffff00 broadcast 211.xx.xx.xx
       ether 00:01:02:7e:4e:19
       media: 10baseT/UTP <half-duplex>
       supported media: 10baseT/UTP <full-duplex> 10baseT/UTP <half-duplex> 10baseT/UTP


ifcondig 의 설정 내용

rc.conf 의 내용

network_interfaces="xl0 lo0"
ifconfig_xl0="DHCP"
gateway_enable="YES"
natd_enable="YES"
natd_interface="xl0"
firewall_enable="YES"
firewall_type="open"
router_enable="NO"
natd_flags="-f /etc/natd.conf"
ifconfig rl0 inet 192.168.0.1 up netmask 255.255.255.0 broadcast 192.168.0.255
대충
그리고natd.conf 의 내용이고요

dynamic
use_sockets
same_ports
unregistered_only
log_denied

부팅할때의 메세지중....
IP packet filtering initialized, divert enabled, rule-based forwarding disabled,
default to deny, logging disabled
Flushed all rules.
00100 54 13302 divert 8668 ip from any to any via xl0
00100 351 20479 allow ip from any to any via rl0
00200 0 0 deny ip from any to 127.0.0.1
65000 54 13302 allow ip from any to any
65535 2 676 deny ip from any to any
Filewall rules loaded, starting divert daemons: natd.
Additional routing options: tcp extensions=NO IP gateway=YES TCP kepalive=YES.
...
다 했는데 ping 은됩니다만 나머지는 다 안됩니다
그리고 rc.firewall 의 내용인데제가 뭘 바꾸기도한듯해서

############
# Setup system for firewall service.
# $FreeBSD: src/etc/rc.firewall,v 1.19.2.4 2000/06/13 07:50:59 ru Exp $

# Suck in the configuration variables.
if [ -f /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
elif [ -f /etc/rc.conf ]; then
. /etc/rc.conf
fi

############
# Define the firewall type in /etc/rc.conf.  Valid values are:
#   open     - will allow anyone in
#   client   - will try to protect just this machine
#   simple   - will try to protect a whole network
#   closed   - totally disables IP services except via lo0 interface
#   UNKNOWN  - disables the loading of firewall rules.
#   filename - will load the rules in the given filename (full path required)
#
# For ``client'' and ``simple'' the entries below should be customized
# appropriately.

############
#
# If you don't know enough about packet filtering, we suggest that you
# take time to read this book:
#
# Building Internet Firewalls
# Brent Chapman and Elizabeth Zwicky
#
# O'Reilly & Associates, Inc
# ISBN 1-56592-124-0
# http://www.ora.com/
#
# For a more advanced treatment of Internet Security read:
#
# Firewalls & Internet Security
# Repelling the wily hacker
# William R. Cheswick, Steven M. Bellowin
#
# Addison-Wesley
# ISBN 0-201-6337-4
# http://www.awl.com/
#

if [ "x$1" != "x" ]; then
firewall_type=$1
fi

############
# Set quiet mode if requested
if [ "x$firewall_quiet" = "xYES" ]; then
fwcmd="/sbin/ipfw -q"
else
fwcmd="/sbin/ipfw"
fi

############
# Flush out the list before we begin.
$fwcmd -f flush

############
# These rules are required for using natd.  All packets are passed to
# natd before they encounter your remaining rules.  The firewall rules
# will then be run again on each packet after translation by natd,
# minus any divert rules (see natd(8)).
if [ "X${natd_enable}" = X"YES" -a "X${natd_interface}" != X"" ]; then
       $fwcmd add divert natd all from any to any via ${natd_interface}
fi

############
# If you just configured ipfw in the kernel as a tool to solve network
# problems or you just want to disallow some particular kinds of traffic
# then you will want to change the default policy to open.  You can also
# do this as your only action by setting the firewall_type to ``open''.

# $fwcmd add 65000 pass all from any to any

############
# Only in rare cases do you want to change these rules
$fwcmd add 100 pass all from any to any via rl0
$fwcmd add 200 deny all from any to 127.0.0.1


# Prototype setups.
if [ "${firewall_type}" = "open" -o "${firewall_type}" = "OPEN" ]; then

$fwcmd add 65000 pass all from any to any

elif [ "${firewall_type}" = "client" ]; then

   ############
   # This is a prototype setup that will protect your system somewhat against
   # people from outside your own network.
   ############

   # set these to your network and netmask and ip
   net="192.168.4.0"
   mask="255.255.255.0"
   ip="192.168.4.17"

   # Allow any traffic to or from my own net.
   $fwcmd add pass all from ${ip} to ${net}:${mask}
   $fwcmd add pass all from ${net}:${mask} to ${ip}

   # Allow TCP through if setup succeeded
   $fwcmd add pass tcp from any to any established

   # Allow IP fragments to pass through
   $fwcmd add pass all from any to any frag

   # Allow setup of incoming email
   $fwcmd add pass tcp from any to ${ip} 25 setup

   # Allow setup of outgoing TCP connections only
   $fwcmd add pass tcp from ${ip} to any setup

   # Disallow setup of all other TCP connections
   $fwcmd add deny tcp from any to any setup

   # Allow DNS queries out in the world
   $fwcmd add pass udp from any 53 to ${ip}
   $fwcmd add pass udp from ${ip} to any 53

   # Allow NTP queries out in the world
   $fwcmd add pass udp from any 123 to ${ip}
   $fwcmd add pass udp from ${ip} to any 123

   # Everything else is denied as default.

elif [ "${firewall_type}" = "simple" ]; then

   ############
   # This is a prototype setup for a simple firewall.  Configure this machine
   # as a named server and ntp server, and point all the machines on the inside
   # at this machine for those services.
   ############

   # set these to your outside interface network and netmask and ip
   oif="rl0"
   onet="192.168.0.1"
   omask="255.255.255.0"
   oip="192.168.4.17"

   # set these to your inside interface network and netmask and ip
   iif="xl0"
   inet="192.168.3.0"
   imask="255.255.255.0"
   iip="192.168.3.17"
#이건 DHCP로 잡은 인터넷인데 이 위에건 뭐라고 쓰죠? 그냥 192.168.0.1 ?

이라고 위어꺼랑 똑같이 아니면은....
   # Stop spoofing
   $fwcmd add deny all from ${inet}:${imask} to any in via ${oif}
   $fwcmd add deny all from ${onet}:${omask} to any in via ${iif}

   # Stop RFC1918 nets on the outside interface
   $fwcmd add deny all from 192.168.0.0:255.255.0.0 to any via ${oif}
   $fwcmd add deny all from any to 192.168.0.0:255.255.0.0 via ${oif}
   $fwcmd add deny all from 172.16.0.0:255.240.0.0 to any via ${oif}
   $fwcmd add deny all from any to 172.16.0.0:255.240.0.0 via ${oif}
   $fwcmd add deny all from 10.0.0.0:255.0.0.0 to any via ${oif}
   $fwcmd add deny all from any to 10.0.0.0:255.0.0.0 via ${oif}

   # Allow TCP through if setup succeeded
   $fwcmd add pass tcp from any to any established

   # Allow IP fragments to pass through
   $fwcmd add pass all from any to any frag

   # Allow setup of incoming email
   $fwcmd add pass tcp from any to ${oip} 25 setup

   # Allow access to our DNS
   $fwcmd add pass tcp from any to ${oip} 53 setup
   $fwcmd add pass udp from any to ${oip} 53
   $fwcmd add pass udp from ${oip} 53 to any

   # Allow access to our WWW
   $fwcmd add pass tcp from any to ${oip} 80 setup

   # Reject&Log all setup of incoming connections from the outside
   $fwcmd add deny log tcp from any to any in via ${oif} setup

   # Allow setup of any other TCP connection
   $fwcmd add pass tcp from any to any setup

   # Allow DNS queries out in the world
   $fwcmd add pass udp from any 53 to ${oip}
   $fwcmd add pass udp from ${oip} to any 53

   # Allow NTP queries out in the world
   $fwcmd add pass udp from any 123 to ${oip}
   $fwcmd add pass udp from ${oip} to any 123

   # Everything else is denied as default.

elif [ "${firewall_type}" != "open" -a -r "${firewall_type}" ]; then
$fwcmd ${firewall_type}
fi
휴 답답합니다..... 답변주시면 감사하겟습니다...


==================================================
우리 인터넷, Daum
평생 쓰는 무료 E-mail 주소 한메일넷
지구촌 한글 검색서비스 Daum FIREBALL
http://www.daum.net
--
To Unsubscribe: send mail to majordomo@kr.FreeBSD.org
with "unsubscribe questions" in the BODY of the message



nat을 이용하여 인터넷을 공유하고 있습니다.
소리바다의 홈페이지의 질문과 답을 보면
nat을 이용한 host들에 대해서는 소리바다가 동작하지
않는다고 나와있는데 그게 이해가 안돼서,
시도해 보게됐고, 지금은 잘되고 있습니다.
리눅스 게시판등을 찾아 보았는데 제가 검색능력이 딸리는지
잘 못찾겠더군요, 그래서 머리싸매고 man page읽으면서 시도해보았습니다.
이미 아시는 분은 아시겠지만 모르시는 분을 잘 이용하세요.
참고로 제 freebsd는 4.1.1-stable #0 입니다.

먼저, 설명(? 추측이겠죠)을 좀 하고 시작할께요.
소리바다가 어케 돌아가는 지는 잘 몰랐기 때문에 deny 되는 패킷을
체크해서 그 포트범위를 추가해 주었습니다.
대충 이렇게 돌아가는 것 같습니다.

먼저 소리바다의 인터넷 서버가 있는 것 같습니다.
주소는 지금 생각나지 않구요, 포트는 8765이고
tcp session을 맺습니다.
이렇게 tcp session을 맺으면 소리바다 서버에 로긴이 됩니다.
그후엔 사용자의 컴들의 file 검색결과는 udp,
file data transfer는 tcp session 을 맺어 통신하는 것 같습니다.
포트는 소리바다에서 정해주게 돼있습니다.
9001-9003, 9101-9103, 9201-9203이런식으로
9901-9903 까지 소리바다 응용프로그램에서 정하는데,
골치아픈것이 랜덤포트 할당이라는 체크박스가 있어서
상대방이 이걸 체크하면 상대방 컴의 9001-9999까지의 범위에서
랜덤으로 포트가 할당되는 것 같습니다
(9100,9200,9300,9400,9500,9600,9700,9800,9900 제외).
이건 소리바다를 인스톨한 사람 맘이기 때문에 어쩔수가 없습니다.
그렇기 때문에 file data transfer를 위해, 더 구체적으로는
우리가 파일을 받아오기 위해서는 포트번호 범위가 9001-9999까지인
tcp session을 요구하는 패킷을 모두 통과되도록
rule을 설정 해야 합니다(tcp setup).
그럼, 우리로부터 나가고 destination 포트가 이범위에 있는 모든
tcp setup 패킷이 허용됩니다.
이것이 보안에 어떤 영향을 미칠지 전 잘 모르겠습니다.

그리고 제일 중요한 것은 소리바다를 인스톨한 내부 lan의 호스트들이
각자 file 검색결과와 file data transfer에 대해 서버역할을 하므로,
ftp 서버를 설정하는 것처럼 port를 redirect시켜줘야합니다(tcp,udp).

1) /etc/rc.conf 의 natd_flags에 직접 쓰거나
2) /etc/natd.conf 등의 파일을 만들어 쓰면 됩니다.
예제(제 설정)는 다음과 같습니다.

1)인 경우 /etc/rc.conf 의 natd_flags에 다음을 추가합니다.
natd_flags="-redirect_port tcp 192.168.0.3:9001-9003 9001-9003
-redirect_port udp 192.168.0.3:9001-9003 9001-9003
-redirect_port tcp 192.168.0.3:9101-9103 9101-9103
-redirect_port udp 192.168.0.3:9101-9103 9101-9103"

여기서 192.168.0.3 과 192.168.0.5는 내부 lan에서 MS 윈도우즈를
사용하는 host들의 ip주소입니다. 각 호스트에서의 소리바다 설정에서
랜덤포트 할당하지 마시고 지정해주세요.

2)인 경우 똑같습니다. 대신 "-"를 빼고 /etc/natd.conf 같은
natd 환경설정 파일에 다음과 같이 추가합니다.

redirect_port tcp 192.168.0.3:9001 9001
redirect_port tcp 192.168.0.3:9002 9002
redirect_port tcp 192.168.0.3:9003 9003
redirect_port udp 192.168.0.3:9001 9001
redirect_port udp 192.168.0.3:9002 9002
redirect_port udp 192.168.0.3:9003 9003
redirect_port tcp 192.168.0.5:9101 9101
redirect_port tcp 192.168.0.5:9102 9102
redirect_port tcp 192.168.0.5:9103 9103
redirect_port udp 192.168.0.5:9101 9101
redirect_port udp 192.168.0.5:9102 9102
redirect_port udp 192.168.0.5:9103 9103

redirect_port tcp 192.168.0.3:9001-9003 9001-9003
이런 형식으로 해도 될겁니다. man 페이지에서 본거 같은데.^^
그리고 2)인 경우는 /etc/rc.conf에서 natd_flags에다가
"-f /etc/natd.conf"를 추가해야합니다.

이제 추가시켜야할 ipfw rule을 나열하겠습니다.
추가시킬 rule 번호는 커널의 기본설정인
65535(모든 것을 거부-default)보다 위에 위치해야합니다.

xl0은 natd interface,
rl0은 내부용 lan에 물려 가상 ip를 받은 interface입니다.
아시는 분은 다 아시겠지만
oif, iif 는 /etc/rc.firewall에서 네트워크카드 이름을
할당하도록 돼있습니다. 제대로 집어넣어주세요.

#------- Added ipfw rules for soribada service -- start
        #---- access to soribada ineternet server
${fwcmd} add pass tcp from any to any 8765 out xmit ${oif} setup
${fwcmd} add pass tcp from any to any 8765 in recv ${iif} setup
        #---- soribada our servers(port redirected servers)
        #---- server 1 ( == host 1 within our lan)
${fwcmd} add pass tcp from any to any 9001-9003 in recv ${oif} setup
${fwcmd} add pass tcp from any to any 9001-9003 out xmit ${iif} setup
        #---- server 2 ( == host 2 within our lan)
${fwcmd} add pass tcp from any to any 9101-9103 in recv ${oif} setup
${fwcmd} add pass tcp from any to any 9101-9103 out xmit ${iif} setup
        #---- getting files from other's server
        #---- clients common rule - file data getting - tcp session
${fwcmd} add pass tcp from any to any 9001-9999 out xmit ${oif} setup
${fwcmd} add pass tcp from any to any 9001-9999 in recv  ${iif} setup
        #---- client 1 within our lan
${fwcmd} add pass udp from any to any 9001-9003 in recv ${oif}
${fwcmd} add pass udp from any to any 9001-9003 out xmit ${iif}
${fwcmd} add pass udp from any 9001-9003 to any out xmit ${oif}
${fwcmd} add pass udp from any 9001-9003 to any in recv ${iif}
        #---- client 2 within our lan
${fwcmd} add pass udp from any 9101-9103 to any out xmit ${oif}
${fwcmd} add pass udp from any 9101-9103 to any in recv ${iif}
${fwcmd} add pass udp from any to any 9101-9103 in recv ${oif}
${fwcmd} add pass udp from any to any 9101-9103 out xmit ${iif}
#------- added ipfw rule for soribada service -- end

이상입니다. 이렇게 하면 현재 nat으로 인터넷을 공유하는
컴퓨터 10대까지는 쓸수 있을것 같군요.

모두 다 하신 다음에 컴을 재부팅시키기 싫으시면,
firewall과 natd가 돌아가는 freebsd에서 local root로

/sbin/ifconfig natd_인터페이스_이름 down  ==> 안전하게 하실 분만^^
/bin/kill -9 `cat /var/run/natd.pid`
/sbin/natd -f /etc/natd.conf -n 인터페이스_이름
/sbin/ipfw -f flush
/bin/sh /etc/rc.firewall
/sbin/ifconfig natd_인터페이스_이름 up    ==> 안전하게 하신 분만--;

해주세요.

오탈자가 있으면 나중에 수정본을 올리겠습니다.
그리고, 저보다 더 깔끔히 정리해 주실 분은 해주세요.

그럼 이만.

--------------------------------------------------------------------------------
 


-- To Unsubscribe: send mail to majordomo@kr.FreeBSD.org with "unsubscribe questions" in the BODY of the message


커널설정을 다음과 같이 하시고
 
# cd /usr/src/sys/i386/conf
# cp GENERIC mykernel
 
mykernel 을 에디터로 수정하시고요
 
# config mykernel
 
컴파일은 3.x 버전이라면(4.x버전에서도 가능)
 
# cd /usr/src/sys/compile/mykernel
# make depend
# make
# make install
 
make install이 성공하였다면
/kernel 이 새로 생성되고, 원래있던 커널은 /kernel.old로 됩니다.
 
에러가 없다면 리부팅 하세요...
 
 
 
----- Original Message -----
From: 최성은
To: questions@kr.FreeBSD.ORG
Sent: Thursday, November 02, 2000 1:50 PM
Subject: BSD에서 NAT 설치 과정


BSD 4.1에서 nat을 설치하려고 하는데,  책도 없구, 마땅한 자세한 정보도 없어서 문의 드립니다.
혹시 자세한 설치 메뉴얼이 있는 곳이나, 정보가 있다면 부탁드립니다.
bsd에 초짜라서 죄송합니다.
 
여기에 올라온 게시물 보고 그냥 커널 컴파일을 하고 있는데 에러가 발생해서요.
커널설정파일이 /usr/src/sys/i386/conf 밑에 GENERIC 이라고 있어서..
다음과 같이 했습니다.
 
 # cp GENERIC mykernel
 # vi mykernel
  맨밑줄에
  options IPFIREWALL
  options IPDIVERT     을 입력하고
# config mykernel 을 하니까.
   make 하라는 메세지가 떠서..
# cd /usr/src 로 가서 거기서
컴파일을 했습니다.
# make
한참동안 컴파일 을 하더니
맨 마지막줄에 에러가 떴습니다.
mkdir /usr/src/gnu/usr.bin/perl/perl/lib/auto/DynaLoader
perl -I/usr/src/gnu/usr.bin/perl/perl/lib -I/usr/src/gnu/usr.bin/perl/perl/lib -I/usr/src/gnu/usr.bin/perl/perl/lib -I/usr/src/gnu/usrm
Perl lib version (5.00503) doesn't match executable version (5.006) at /usr/src/gnu/usr.bin/perl/perl/lib/Config.pm line 7.
Compilation failed in require at DynaLoader_pm.PL line 2.
BEGIN failed--compilation aborted at DynaLoader_pm.PL line 2.
*** Error code 255
Stop in /usr/src/gnu/usr.bin/perl/perl/ext/DynaLoader.
*** Error code 1
Stop in /usr/src/gnu/usr.bin/perl/perl.
*** Error code 1
Stop in /usr/src/gnu/usr.bin/perl.
*** Error code 1
Stop in /usr/src/gnu/usr.bin.
*** Error code 1
Stop in /usr/src/gnu.
*** Error code 1
Stop in /usr/src.
*** Error code 1

이다음에 그냥 make install하면 되는 건가요?
그 다음에 어떻게 해야하는지 아니면 잘못된건지 부탁드립니다.
 
 
 
 
 NAT 안쪽의 사설망으로 외부에서 컨넥션을 갖을려면,
IP Mapping을 해주어야 합니다. 공인 IP와 내부 사설
IP를 1:1 매핑해주고, 외부에서 공인 IP로 접속을 하면
NAT가 내부 IP로 매핑시켜 줍니다. FreeBSD의 natd에서는
-redirect_address 옵션으로 가능합니다.

--
Seung-young Kim          http://www.hongik.com
Enable your web site with Hongik Internet, Inc.
--
To Unsubscribe: send mail to majordomo@kr.FreeBSD.org
with "unsubscribe questions" in the BODY of the message


적어도 FIREWALL 옵션이 커널에 들어가야 하는건 아닌가요?

natd(8) man page를 보면

The following steps are necessary before attempting to run natd:
1.   Build a custom kernel with the following options:
options IPFIREWALL
options IPDIVERT

이렇게 되면 default to deny로 설정되어서 open 해주지 않는
이상 natd를 쓰지 못할텐데요? 최소한 open으로 만들어주는 방화벽
설정은 필요한 것 아닌지요.

1.   You will need to adjust the /etc/rc.firewall script to taste.  If
  you are not interested in having a firewall, the following lines
  will do:

/sbin/ipfw -f flush
/sbin/ipfw add divert natd all from any to any via ed0
/sbin/ipfw add pass all from any to any

여기에 나와있네요. 설정이 전혀 없다는 것은 위의 설정이 하나도
없단 이야기인가요? 어떻게 하셨는지 궁금하네요.

On Sat, Feb 03, 2001 at 03:12:35AM +1000, Seung-joo Lee wrote:
> You wrote:
> 그리고 한가지 첨언을 하자면,
> natd를 위해서 항상 Firewall을 연계시켜 생각하시는데 그렇지가 않거든요.
> 보안상의 이유로 Firewall과 연계하여 사용하실 수는 있을지 몰라도
> natd를 위해서 Firewall 설정이 필요한 것은 아닙니다.
> 저의 경우 지금 현재 Firewall 설정 전혀 없이 natd를 하고 있거든요.
> 물론 저는 dial-up 접속을 통한 ppp 연결이긴 합니다만 이것이 차이가 있다고
> 생각되지는 않습니다. 여기에 차이가 있는 것인가요?
>

--
Thanks
icq UIN 104946812, Kwangyul Seo <skyul@postech.edu>
--
To Unsubscribe: send mail to majordomo@kr.FreeBSD.org
with "unsubscribe questions" in the BODY of the message


**  Kwangyul SEO writes:
KS> 여기에 나와있네요. 설정이 전혀 없다는 것은 위의 설정이 하나도
KS> 없단 이야기인가요? 어떻게 하셨는지 궁금하네요.
KS>

ppp 의 -nat 옵션을 이용하면, 방화벽 필요 없어요...

KS> On Sat, Feb 03, 2001 at 03:12:35AM +1000, Seung-joo Lee wrote:
>  You wrote:
>  그리고 한가지 첨언을 하자면,
>  natd를 위해서 항상 Firewall을 연계시켜 생각하시는데 그렇지가 않거든요.
>  보안상의 이유로 Firewall과 연계하여 사용하실 수는 있을지 몰라도
>  natd를 위해서 Firewall 설정이 필요한 것은 아닙니다.
>  저의 경우 지금 현재 Firewall 설정 전혀 없이 natd를 하고 있거든요.
>  물론 저는 dial-up 접속을 통한 ppp 연결이긴 합니다만 이것이 차이가 있다고
>  생각되지는 않습니다. 여기에 차이가 있는 것인가요?

KS>
KS> --
KS> Thanks
KS> icq UIN 104946812, Kwangyul Seo <skyul@postech.edu>
KS> --
KS> To Unsubscribe: send mail to majordomo@kr.FreeBSD.org
KS> with "unsubscribe questions" in the BODY of the message
KS>
KS>
--
이재호
--
To Unsubscribe: send mail to majordomo@kr.FreeBSD.org
with "unsubscribe questions" in the BODY of the message
]


http://www.kr.freebsd.org/handbook/handbook85.shtml#158

을 참고하세요.

On Tue, Feb 06, 2001 at 05:46:44PM +0900, 정주상 wrote:
> 전 프비 초보인데요.
> 회사에서 프비로 방화벽을 설정할려구 그러는데
> 왕초보라서 아무것두 몰르겠습니다.
> 그래서 말인데 지침서나 안내서 좀 알려주시기
> 바랍니다.
> 프비 사용자님들에게 가르침 부탁드립니다.
--
To Unsubscribe: send mail to majordomo@kr.FreeBSD.org
with "unsubscribe questions" in the BODY of the message


참고 사이트

http://www.freebsd.org/handbook/firewalls.html
http://www.obfuscation.org/ipf/
http://www.freebsddiary.org/topics.php3#firewalls
http://www.freebsddiary.org/topics.php3#ipfilter
http://www.freebsddiary.org/topics.php3#nat
http://www.defcon1.org/html/NATD-config/firewall-setup/ipfw-1.html
http://www.daemonnews.org/200102/armoring.html#3

참고 도서

"Firewalls and Internet" Security by Cheswick and Bellovin Adisson Wesley
"Building Internet Firewalls 2nd edition" O'Reilly.

On Tue, Feb 06, 2001 at 05:46:44PM +0900, 정주상 wrote:
> 전 프비 초보인데요.
> 회사에서 프비로 방화벽을 설정할려구 그러는데
> 왕초보라서 아무것두 몰르겠습니다.
> 그래서 말인데 지침서나 안내서 좀 알려주시기
> 바랍니다.
> 프비 사용자님들에게 가르침 부탁드립니다.?淸R{.n?돴?깁??텎쉸듶줷?뮸큼?H?溫 "???궝?園z????ax긞뉙낂옽?
>

--
Thanks
icq UIN 104946812, Kwangyul Seo <skyul@postech.edu>
--


----------------------------------------------------------------------
----------------------------------------------------------------------
안녕하세요.

> ipfw list:
> ... divert 8668 ip from any to any via ed0
> ... divert 8668 ip from any to any via rl0

여기서 두 번째 라인은 필요가 없을텐데요. 이건 FreeBSD 서버가
양쪽 방향을 다 변환한다는 뜻이 되어버리니깐요. 첫째줄만 있으면
내부 네트웍에서 인터넷을 사용하는데 문제가 없습니다.

> 저렇게 하면 내부 네트웍에서 밖으로 접속하는 것은 잘 되는것 같은데, 192.168.0.1즉
> , 프비가 깔린 컴퓨터에 접속이 안되네요.

그리고 multi-homed의 경우 접속하고자 하는 데몬이 양쪽에 모두
바인딩하고 있는지 확인해보세요. inetd의 경우 -a 옵션을 준다던지
하면 하나의 NIC만 바인당하게 되거든요.

> 하나 더는, 특정 포트를 특정 컴퓨터의 특정 포트로 매핑하고 싶습니다.
> 예를들면, FreeBSD 80번으로 오는 소켓을 192.168.0.4:80으로 오게...(웹 서비스만 특
> 정 컴퓨터에서 하고싶거든요..)

다른 방법도 있겠지만 natd를 사용한다면 natd의 port_redirect 기능을
이용하시면 편합니다. 내부에 192.168.0.2 호스트에서 웹서비스만 제공하려면

redirect_port tcp 192.168.0.2:80 80

이런 식으로 하면 natd를 돌리는 FreeBSd에 오는 80번 서비스를 내부에 있는
192.168.0.2의 80번 포트로 redirect시켜 줍니다.

도움 되셨길 바랍니다.


--
Thanks
icq UIN 104946812, Kwangyul Seo <skyul@postech.edu>
--


----------------------------------------------------------------------
----------------------------------------------------------------------
네... 저도 역시 며칠간 머리에서 김나는줄 알았읍니다.

저역시 배워나가는 중이라 그렀지만 제 경험을 적어보면...

1. 구성
   ISP---Cable Modem---de0---FreeBSD box---ed0---Hub---Windows 98 box

   FreeBSD box internal IP - 192.168.1.1
   Windows 98 internal IP - 192.168.1.2
   de0 -- 바깥쪽 ethernet card
   ed0 -- 안쪽 ethernet card (internal network)


2. 커널 컴파일
   options IPFIREWALL
   options IPDIVERT

   나머지는 적당히 상황에 맞게 하시고...

3. 네트웍이 잘 셋업이 되어있는지 확인하시고 (바깥쪽, 안쪽)
   라우팅 테이블이 업데이트되야 되더군요. 안 그러면 Windows에
   핑을 보내면 찾지를 못합니다.
   route add -net 192.168.1.0 netmask 255.255.255.0 ed0

4. firewall
   /etc/rc.firewall 스크립을 편집하시든지 rc.conf에 그냥 쓰시던지
   하셔서...
   /sbin/ipfw -f flush
   /sbin/ipfw add divert natd all from any to any via de0
   /sbin/ipfw add pass all from any to any
   이 세 줄이 꼭 필요하더군요, 제 경우는.

5. 나머지
   /etc/rc.conf 에...
   gateway_enable="YES"
   firewall_enable="YES"
   natd_enable="YES"

6. 마지막으로
   sysctl -w net.inet.ip.forwarding=1
   natd -l -s -n de0 -redirect_port tcp 192.168.1.2:2121 2121

   natd 메뉴얼에 보면 sysctl 대신에 gateway_enabled="YES" 만
   써주면 된다고 나와 있는데 왜그런지 제 경우는 죽어도 안되더라구요.
   그래서 고민하지 않고 그냥 sysctl 로 끝내 버렸읍니다.


7. 정리하면 (저의 초라한? 셋업)
   in /etc/rc.conf
   ....
   /sbin/ipfw -f flush
   /sbin/ipfw add divert natd all from any to any via de0
   /sbin/ipfw add pass all from any to any
   gateway_enable="YES"
   firewall_enable="YES"
   natd_enable="YES"
   sysctl -w net.inet.ip.forwarding=1
   natd -l -s -n de0 -redirect_port tcp 192.168.1.2:2121 2121

8. Windows 상에서 IP를 계획하신데로 주시고, DNS는 ISP에서
주신걸로 하시고... 뭐 등등....

9. Reboot


이렇게 했더니 귀신같이 잘 되더군요.
일단은 NAT이 돌아가고 있으니 여기에 허술한 제 방화벽을 보강하려고
생각중입니다. (시간이 나면... 언제가 될꼬...)
그럼 고수님들 조언 많이 해 주시고...
이만....휘리릭~~~

yoon@nacse.org


----------------------------------------------------------------------
----------------------------------------------------------------------
On Fri, 9 Mar 2001, 김성현 wrote:

> 안녕하세요?
>
> FreeBSD로 방화벽을 만들고 있는 사용자입니다.
>
> NAT를 이용해서 방화벽 (Kernel의 divert 기능을 이용해서, 내부의 사용자가
> 외부로 접속할 수 있고, 외부 사용자가 내부로 접근할 수 있으나, Firewall을
> 통과해야 하는)을 구성하는 중입니다.
>
> 대부분의 NAT 자료들이 ppp나 ADSL과 같은 마스커레이딩류의 자료들이어서,
> 쉽고 참고할만한 자료가 없더군요.
>
> Divert 기능을 이용해서 외부/내부의 패킷 교류를 할 수 있고, 패킷 필터링을
> 할 수 있는 서버를 구축하고 싶은데...
>
> 쉽게 되지를 않고 있습니다.
>
> 조언을 구하기 위해서 글을 남깁니다.
>
> 많은 조언 부탁 드리겠습니다!