[NetBSD 3.0] NAT / Router / Gateway opzetten

Pagina: 1
Acties:

  • dr.dunno
  • Registratie: Maart 2002
  • Niet online
Oke, ik ben relatief nieuw met dit onderwerp, maar ik hoop desalniettemin hier toch wel de hulp te kunnen krijgen waar ik al dagen naar zoek.

Situatie is als volgt:
ADSL2+ aansluiting (16/1.2 MBps), stuk of 8 zwaar trekkende computers waarvan 2 servers, huidige e-tech modem/router/gateway begeeft het 5x per dag. En ja, het is een e-tech, maar dat is de enige die deze snelheid haalt op deze afstand, dus daar moet ik het even mee doen. :)

netwerk configuratie
range: 192.168.88.x
subnet: 255.255.255.0
huidige gateway ip: 192.168.88.254
nieuwe gateway ip: 192.168.88.1

hardware (die terzake zou kunnen doen)
• AMD Duron 1900+ CPU
• Shuttle mammaplankje
• 256MB DDR
• 60GB HDD
• simpel videokaartje
• 2x realtek netwerkkaart (die kunnen worden vervangen als daar noodzaak toe is, nu nog niet)

Dit ding ligt in een ruimte zonder monitor/keyboard en voorlopig nog in een testopstelling met alleen een van de netwerkkabels aangesloten.

rtk0 is de kaart voor de LAN
rtk1 is de kaart voor de WAN

Mezelf door diverse tutorials heengeworsteld hebbende (ruim een dag of 10), ben ik tot een punt gekomen dat ik alles wel werkend heb gekregen voor zover ik weet, alleen het NAT gebeuren is me nog een raadsel. Eigenlijk vind ik vrij summiere tutorials op sites als www.netbsd.org en www.freebsd.org , linux heb ik nauwelijks ervaring mee ook dus dat helpt ook niet.

De bestanden die ertoe doen (volgens mij) zijn:
- /etc/rc.conf
- /etc/hosts [hoeft volgens mij nog niks mee te gebeuren]
- /etc/ipf.conf
- /etc/ipnat.conf [bestaat nog niet]


/etc/rc.conf
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#       $NetBSD: rc.conf,v 1.96 2000/10/14 17:01:29 wiz Exp $
#
# see rc.conf(5) for more information.
#
# Use program=YES to enable program, NO to disable it. program_flags are
# passed to the program on the command line.
#

# Load the defaults in from /etc/defaults/rc.conf (if it's readable).
# These can be overridden below.
#
if [ -r /etc/defaults/rc.conf ]; then
        . /etc/defaults/rc.conf
fi

# If this is not set to YES, the system will drop into single-user mode.
#
rc_configured=YES
# Add local overrides below
#
hostname=dunnogateway1
dhclient=YES
dhclient_flags="rtk1"
ifconfig_rtk0="inet 192.168.88.1 netmask 0xffffff00"

wscons=YES
sshd=YES
# NAT &
# IPFILTER
# http://www.freebsd.org/doc/nl/books/handbook/firewalls-ipf.html
#
ipfilter_enable="YES"             # Start ipf firewall
ipfilter_rules="/etc/ipf.conf"    # laad regels uit het doelbestand, voorheen i$
ipmon_enable="YES"                # Start IP monitor log
ipmon_flags="-Ds"                 # D = start als daemon
                                  # s = log naar syslog
                                  # v = log tcp window, ack, seq
                                  # n = vertaal IP & poort naar namen

# LAN achter firewall dat ip's uit private reeks gebruikt, dus:
gateway_enable="YES"              # Schakel in als LAN gateway
ipnat_enable="YES"                # Start ipnat functie
ipnat_rules="/etc/ipnat.conf"     # bestand met regels voor ipnat


/etc/hosts
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#       $NetBSD: hosts,v 1.7 2004/08/29 13:26:17 chs Exp $
#
# Host Database
# This file should contain the addresses and aliases
# for local hosts that share this file.
# It is used only for "ifconfig" and other operations
# before the nameserver is started.
#
#
::1                     localhost localhost.
127.0.0.1               localhost localhost.
#
# RFC 1918 specifies that these networks are "internal".
# 10.0.0.0      10.255.255.255
# 172.16.0.0    172.31.255.255
# 192.168.0.0   192.168.255.255


/etc/ipf.conf (grotendeels overgenomen, maar aangepast)
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
############# Start of IPF rules script #########################
#
# http://www.freebsd.org/doc/en/books/handbook/firewalls-ipf.html
#################################################################
# No restrictions on Inside LAN Interface for private network
# Not needed unless you have LAN
#################################################################

#pass out quick on xl0 all
#pass in quick on xl0 all

#################################################################
# No restrictions on Loopback Interface
#################################################################
pass in quick on lo0 all
pass out quick on lo0 all

#################################################################
# Interface facing Public Internet (Outbound Section)
# Interrogate session start requests originating from behind the
# firewall on the private network
# or from this gateway server destine for the public Internet.
#################################################################

# Allow out access to my ISP's Domain name server.
# xxx must be the IP address of your ISP's DNS.
# Dup these lines if your ISP has more than one DNS server
# Get the IP addresses from /etc/resolv.conf file
#
# PRIMAIRE DNS:
pass out quick on rtk1 proto tcp from any to 213.211.129.21 port = 53 flags S keep state
pass out quick on rtk1 proto udp from any to 213.211.129.21 port = 53 keep state
#
# SECUNDAIRE DNS:
pass out quick on rtk1 proto tcp from any to 213.211.129.22 port = 53 flags S keep state
pass out quick on rtk1 proto udp from any to 213.211.129.22 port = 53 keep state

# Allow out access to my ISP's DHCP server for cable or DSL networks.
# This rule is not needed for 'user ppp' type connection to the
# public Internet, so you can delete this whole group.
# Use the following rule and check log for IP address.
# Then put IP address in commented out rule & delete first rule
pass out log quick on rtk1 proto udp from any to any port = 67 keep state
#pass out quick on rtk1 proto udp from any to z.z.z.z port = 67 keep
state

# FUNCTIE: WEBBROWSEN
#
# Allow out non-secure standard www function
pass out quick on rtk1 proto tcp from any to any port = 80 flags S keep state
# Allow out secure www function https over TLS SSL
pass out quick on rtk1 proto tcp from any to any port = 443 flags S keep
state

# FUNCTIE: E-MAILEN
# Allow out send & get email function
pass out quick on rtk1 proto tcp from any to any port = 110 flags S keep state
pass out quick on rtk1 proto tcp from any to any port = 25 flags S keep state
# Allow out send & get email function IMAP VIA SSL OOK!
pass out quick on rtk1 proto tcp from any to any port = 110 flags S keep state

# FUNCTIE: NTTP
# Allow out Time
pass out quick on rtk1 proto tcp from any to any port = 37 flags S keep state
# Allow out nntp news
pass out quick on rtk1 proto tcp from any to any port = 119 flags S keep state

# FUNCTIE: FTP / TELNET en OVERIGEN
# Allow out gateway & LAN users non-secure FTP ( both passive & active modes)
# ====> This function uses the IPNAT built in FTP proxy function coded in
# the nat rules file to make this single rule function correctly.
# If you want to use the pkg_add command to install application packages
# on your gateway system you need this rule.
# DISABLED pass out quick on rtk1 proto tcp from any to any port = 21 flags S keep state
# ====> IN DIT GEVAL GEBRUIKT HET GEEN FTP PROXY
# Allow out LAN PC client FTP to public Internet
# Active and passive modes
pass out quick on rtkl proto tcp from any to any port = 21 flags S keep state
# Allow out passive mode data channel high order port numbers
pass out quick on rtk1 proto tcp from any to any port > 1024 flags S keep state
# Active mode let data channel in from FTP server
pass in quick on rtk1 proto tcp from any to any port = 20 flags S keep state


# Allow out secure FTP, Telnet, and SCP
# This function is using SSH (secure shell)
pass out quick on rtk1 proto tcp from any to any port = 22 flags S keep state

# Allow out non-secure Telnet
pass out quick on rtk1 proto tcp from any to any port = 23 flags S keep state

# Allow out FBSD CVSUP function
pass out quick on rtk1 proto tcp from any to any port = 5999 flags S keep state

# Allow out ping to public Internet
pass out quick on rtk1 proto icmp from any to any icmp-type 8 keep state
# Allow out whois for LAN PC to public Internet
pass out quick on rtk1 proto tcp from any to any port = 43 flags S keep state

# Block and log only the first occurrence of everything
# else that's trying to get out.
# This rule enforces the block all by default logic.
block out log first quick on rtk1 all



#################################################################
# Interface facing Public Internet (Inbound Section)
# Interrogate packets originating from the public Internet
# destine for this gateway server or the private network.
#################################################################

# Block all inbound traffic from non-routable or reserved address spaces
block in quick on rtk1 from 192.168.0.0/16 to any    #RFC 1918 private IP
block in quick on rtk1 from 172.16.0.0/12 to any     #RFC 1918 private IP
block in quick on rtk1 from 10.0.0.0/8 to any        #RFC 1918 private IP
block in quick on rtk1 from 127.0.0.0/8 to any       #loopback
block in quick on rtk1 from 0.0.0.0/8 to any         #loopback
block in quick on rtk1 from 169.254.0.0/16 to any    #DHCP auto-config
block in quick on rtk1 from 192.0.2.0/24 to any      #reserved for docs
block in quick on rtk1 from 204.152.64.0/23 to any   #Sun cluster interconnect
block in quick on rtk1 from 224.0.0.0/3 to any       #Class D & E multicast

##### Block a bunch of different nasty things. ############
# That I do not want to see in the log

# Block frags
block in quick on rtk1 all with frags
# Block short tcp packets
block in quick on rtk1 proto tcp all with short

# block source routed packets
block in quick on rtk1 all with opt lsrr
block in quick on rtk1 all with opt ssrr

# Block nmap OS fingerprint attempts
# Log first occurrence of these so I can get their IP address
block in log first quick on rtk1 proto tcp from any to any flags FUP

# Block anything with special options
block in quick on rtk1 all with ipopts

# Block public pings
block in quick on rtk1 proto icmp all icmp-type 8

# Block ident
block in quick on rtk1 proto tcp from any to any port = 113

# Block all Netbios service. 137=name, 138=datagram, 139=session
# Netbios is MS/Windows sharing services.
# Block MS/Windows hosts2 name server requests 81
block in log first quick on rtk1 proto tcp/udp from any to any port = 137
block in log first quick on rtk1 proto tcp/udp from any to any port = 138
block in log first quick on rtk1 proto tcp/udp from any to any port = 139
block in log first quick on rtk1 proto tcp/udp from any to any port = 81

# Allow traffic in from ISP's DHCP server. This rule must contain
# the IP address of your ISP's DHCP server as it's the only
# authorized source to send this packet type. Only necessary for
# cable or DSL configurations. This rule is not needed for
# 'user ppp' type connection to the public Internet.
# This is the same IP address you captured and
# used in the outbound section.
pass in quick on rtk1 proto udp from 213.211.0.0 to any port = 68 keep state

# Allow in standard www function because I have apache server
pass in quick on rtk1 proto tcp from any to any port = 80 flags S keep state
# Allow in non-secure Telnet session from public Internet
# labeled non-secure because ID/PW passed over public Internet as clear text.
# Delete this sample group if you do not have telnet server enabled.
#pass in quick on rtk1 proto tcp from any to any port = 23 flags S keep state

# Allow in secure FTP, Telnet, and SCP from public Internet
# This function is using SSH (secure shell)
pass in quick on rtk1 proto tcp from any to any port = 22 flags S keep state

# Block and log only first occurrence of all remaining traffic
# coming into the firewall. The logging of only the first
# occurrence stops a .denial of service. attack targeted
# at filling up your log file space.
# This rule enforces the block all by default logic.
block in log first quick on rtk1 all

################### End of rules file#####################################
# SEE http://www.freebsd.org/doc/en/books/handbook/firewalls-ipf.html
# FOR FURTHER DOCUMENTATION, ALSO ON HOW TO RELOAD FIREWALL RULES


Van begin tot eind heb ik tutorials bekeken en uitgevoerd, om tot dit geheel te komen. DHCP werkt momenteel via rtk1 en wat dat betreft kan hij dus zelf gewoon verbinding maken met het modem zodra deze in bridge staat en deze direct op rtk1 is aangesloten.

Waar ik mee zit is dat ik niet het idee heb dat dat NAT helemaal klopt (en mogelijk het daarmee samenhangende firewall gebeuren). Sowieso is alle documentatie hierover heel erg summier en is het me totaal niet duidelijk hoe nu die NAT regels werken. Ook hebben tutorials het er vaak over om 'even in de kernel te kijken' of wat opties aanstaan ; nou ik heb geen enkel idee waar ik daarvoor moet kijken :{

Ik heb d'r over nagedacht om gewoon een standaard oplossing te gebruiken zoals smoothwall, maar ten eerste leer ik daar niks van (zakelijk heb ik ook nog een server in a'dam hangen met FreeBSD erop namelijk en ik heb me dat ook eigen moeten maken (en nog steeds natuurlijk) om daar zelf ook wat mee te kunnen (door bevriend persoon geïnstalleerd ooit en wordt bijgehouden ook). Verder wil ik ook graag wat kunnen rommelen met de configuratie op mijn eigen manier, wat toch nooit lukt met zo'n oplossing.

En nogmaals, ben nog lerende, dus bedankt voor je geduld, ga er niet vanuit dat ik alles weet want dat doe ik *zeker* niet :+

Graag wat hulp B)

PS Ik heb natuurlijk ook heel GoT door zitten spitten; ik vond daarbij niets bruikbaars voor mijn situatie, hoogstens voor linux (maar dat is dus niet nuttig).

  • blaataaps
  • Registratie: Juli 2001
  • Niet online
http://www.netbsd.org/gui...l#chap-net-practice-ipnat is toch behoorlijk duidelijk of niet? :)
Over de kernelcompile-opties hoef je je niet druk te maken volgens mij, GENERIC kan al wat jij wil.
Ik zou sowieso beginnen met een veel kleinere ipf.conf, zodat je zelf precies weet wat erinstaat en wat er gebeurt, dat is veel nuttiger (en leerzamer) dan een enorme config overnemen.
En als je toch met een vers systeem begint, kan ik je aanraden ook eens naar pf te kijken in plaats van ipv, http://www.openbsd.org/faq/pf/nat.html gaat over de nat-configuratie ervan.