Hi,
I have a combination mail/web/etc server that also acts as a firewall. I am replacing a Linux (iptables) box with Solaris (ipfilter), so please bear with me :) .. I went through the FAQ, and think I have a fairly reasonable firewall for the host itself, but now I am attempting to restrict what my NAT users can do. I am either picking very poor search terms (quite likely) or I cant find anything about this in the archives.
I want to be able to allow the server itself to create an SMTP connection wherever it pleases (as it is a mail server) but I want to restrict the users on the network to only be able to create an SMTP connection to the box itself (and maybe a small list of exceptions) to prevent viruses from spamming the world and having my server NAT the connection. If I am reading this correctly, I should use the "block out" rules to stop packets, but the NAT happens first, so I would have to put my "own" IP in place, which would block my servers outbound SMTP connections.
I did this with iptables -A FORWARD type rules previously because they only affected "forwarded" packets, and not IN our OUT.. I guess I need to know if there is something equivalent? or maybe I am going about it all wrong?
Thanks in advance, Tommy
** my "hme0" interface has an "internal" IP in my lab for now, but will be on a public network when its deployed, but that shouldn't make any difference wrt my question above **
(not sure if any of this is relevant, but here goes)
bash-2.05# uname -a
SunOS dccmail 5.9 Generic_112233-12 sun4u sparc SUNW,Ultra-60
bash-2.05# isainfo -kv
64-bit sparcv9 kernel modules
bash-2.05# ifconfig -a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet 127.0.0.1 netmask ffffff00
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 10.1.226.40 netmask ffffff00 broadcast 10.1.226.255
ether 8:0:20:b2:39:9
qfe0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
inet 10.0.0.1 netmask ffffff00 broadcast 10.0.0.255
ether 8:0:20:b2:39:9
bash-2.05# netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- -------------------- ----- ----- ------ ---------
10.1.226.0 10.1.226.40 U 1 7 hme0
10.0.0.0 10.0.0.1 U 1 8 qfe0
224.0.0.0 10.1.226.40 U 1 0 hme0
default 10.1.226.33 UG 1 95
127.0.0.1 127.0.0.1 UH 2 2 lo0
bash-2.05# netstat -i
Name Mtu Net/Dest Address Ipkts Ierrs Opkts Oerrs Collis Queue
lo0 8232 localhost localhost 899 0 899 0 0 0
hme0 1500 dccmail.dccmail.net dccmail.dccmail.net 5935 0 5178 0 0 0
qfe0 1500 local.dccmail.net local.dccmail.net 3945 0 4166 0 0 0
bash-2.05# netstat -s -P ip
IPv4 ipForwarding = 1 ipDefaultTTL = 255
ipInReceives = 9801 ipInHdrErrors = 0
ipInAddrErrors = 0 ipInCksumErrs = 0
ipForwDatagrams = 7641 ipForwProhibits = 0
ipInUnknownProtos = 0 ipInDiscards = 0
ipInDelivers = 2938 ipOutRequests = 1763
ipOutDiscards = 0 ipOutNoRoutes = 0
ipReasmTimeout = 60 ipReasmReqds = 0
ipReasmOKs = 0 ipReasmFails = 0
ipReasmDuplicates = 0 ipReasmPartDups = 0
ipFragOKs = 0 ipFragFails = 0
ipFragCreates = 0 ipRoutingDiscards = 0
tcpInErrs = 0 udpNoPorts = 116
udpInCksumErrs = 0 udpInOverflows = 0
rawipInOverflows = 0 ipsecInSucceeded = 0
ipsecInFailed = 0 ipInIPv6 = 0
ipOutIPv6 = 0 ipOutSwitchIPv6 = 155bash-2.05# ipf -V
ipf: IP Filter: v3.4.32 (496)
Kernel: IP Filter: v3.4.32
Running: yes
Log Flags: 0 = none set
Default: pass all, Logging: available
Active list: 0
bash-2.05# ipfstat
dropped packets: in 0 out 0
non-data packets: in 1 out 0
no-data packets: in 0 out 0
non-ip packets: in 0 out 0
bad packets: in 0 out 0
copied messages: in 0 out 259
IPv6 packets: in 0 out 0
input packets: blocked 78 passed 8560 nomatch 0 counted 0 short 0
output packets: blocked 155 passed 8143 nomatch 0 counted 0 short 0
input packets logged: blocked 0 passed 0
output packets logged: blocked 0 passed 0
packets logged: input 0 output 0
log failures: input 0 output 0
fragment state(in): kept 0 lost 0
fragment state(out): kept 0 lost 0
packet state(in): kept 0 lost 0
packet state(out): kept 340 lost 1
ICMP replies: 0 TCP RSTs sent: 0
Invalid source(in): 0
Result cache hits(in): 284 (out): 234
IN Pullups succeeded: 0 failed: 0
OUT Pullups succeeded: 1 failed: 0
Fastroute successes: 0 failures: 0
TCP cksum fails(in): 0 (out): 0
Packet log flags set: (0)
none
bash-2.05# ipfstat -io
pass out quick on lo0 from any to any
pass out quick on qfe0 from any to any
block out log level local1.info from any to any
block out quick on hme0 from any to 192.168.0.0/16
block out quick on hme0 from any to 172.16.0.0/12
block out quick on hme0 from any to 0.0.0.0/8
block out quick on hme0 from any to 127.0.0.0/8
block out quick on hme0 from any to 169.254.0.0/16
block out quick on hme0 from any to 192.0.2.0/24
block out quick on hme0 from any to 204.152.64.0/23
block out quick on hme0 from any to 224.0.0.0/3
pass out quick on hme0 proto tcp from any to any keep state keep frags
pass out quick on hme0 proto udp from any to any keep state keep frags
pass out quick on hme0 proto icmp from any to any keep state
pass in quick on lo0 from any to any
pass in quick on qfe0 from any to any
block in log level local1.info from any to any
block return-rst in log level local1.info proto tcp from any to any
block return-icmp(port-unr) in log level local1.info proto udp from any to any
block return-icmp(port-unr) in log level local1.info proto icmp from any to any
block in quick on hme0 from 192.168.0.0/16 to any
block in quick on hme0 from 172.16.0.0/12 to any
block in quick on hme0 from 127.0.0.0/8 to any
block in quick on hme0 from 0.0.0.0/8 to any
block in quick on hme0 from 169.254.0.0/16 to any
block in quick on hme0 from 192.0.2.0/24 to any
block in quick on hme0 from 204.152.64.0/23 to any
block in quick on hme0 from 224.0.0.0/3 to any
block in log quick on hme0 from any to 69.15.138.72/32
block in log quick on hme0 from any to 69.15.138.79/32
pass in quick on hme0 proto icmp from any to any icmp-type echo
pass in quick on hme0 proto tcp from any to any port = 25 flags S/FSRPAU keep state
pass in quick on hme0 proto tcp from any to any port = 22 flags S/FSRPAU keep state
pass in quick on hme0 proto tcp from any to any port = 80 flags S/FSRPAU keep state
pass in quick on hme0 proto tcp from any to any port = 443 flags S/FSRPAU keep state
pass in quick on hme0 proto tcp from any to any port = 21 flags S/FSRPAU keep state
block return-rst in quick proto tcp from any to any port = 137
block return-rst in quick proto tcp from any to any port = 138
block return-rst in quick proto tcp from any to any port = 139
block return-icmp(port-unr) in quick proto udp from any to any port = 137
block return-icmp(port-unr) in quick proto udp from any to any port = 138
block return-icmp(port-unr) in quick proto udp from any to any port = 139
bash-2.05# ipnat -slv
mapped in 4017 out 3413
added 252 expired 216
no memory 0 bad nat 0
inuse 23
rules 2
wilds 0
table ffffffff7ffffc40 list 3000158e910
List of active MAP/Redirect filters:
map hme0 10.0.0.0/24 -> 0.0.0.0/32 portmap tcp/udp 10000:40000
map hme0 10.0.0.0/24 -> 0.0.0.0/32
List of active sessions:
MAP 10.0.0.2 64270 <- -> 10.1.226.40 10203 [10.1.224.5 53]
age 364 use 0 sumd 0xef4/0xef4 pr 17 bkt 11129/14990 flags 2 drop 0/0
ifp hme0 bytes 201 pkts 2 e227
MAP 10.0.0.2 64269 <- -> 10.1.226.40 10202 [10.1.224.5 53]
age 364 use 0 sumd 0xef4/0xef4 pr 17 bkt 11128/14989 flags 2 drop 0/0
ifp hme0 bytes 238 pkts 2 e227
MAP 10.0.0.2 63303 <- -> 10.1.226.40 10201 [64.81.102.240 993]
age 863831 use 0 sumd 0x12b9/0x12b9 pr 6 bkt 12432/875 flags 1 drop 0/0
ifp hme0 bytes 14112 pkts 87 e227
MAP 10.0.0.2 64266 <- -> 10.1.226.40 10200 [10.1.224.5 53]
age 342 use 0 sumd 0xef5/0xef5 pr 17 bkt 11125/14987 flags 2 drop 0/0
ifp hme0 bytes 201 pkts 2 e227
MAP 10.0.0.2 64265 <- -> 10.1.226.40 10199 [10.1.224.5 53]
age 342 use 0 sumd 0xef5/0xef5 pr 17 bkt 11124/14986 flags 2 drop 0/0
ifp hme0 bytes 238 pkts 2 e227
MAP 10.0.0.2 64262 <- -> 10.1.226.40 10198 [10.1.224.5 53]
age 340 use 0 sumd 0xef7/0xef7 pr 17 bkt 11121/14985 flags 2 drop 0/0
ifp hme0 bytes 201 pkts 2 e227
MAP 10.0.0.2 64261 <- -> 10.1.226.40 10197 [10.1.224.5 53]
age 340 use 0 sumd 0xef7/0xef7 pr 17 bkt 11120/14984 flags 2 drop 0/0
ifp hme0 bytes 238 pkts 2 e227
MAP 10.0.0.2 64260 <- -> 10.1.226.40 10196 [10.1.224.5 53]
age 340 use 0 sumd 0xef7/0xef7 pr 17 bkt 11119/14983 flags 2 drop 0/0
ifp hme0 bytes 238 pkts 2 e227
MAP 10.0.0.2 64259 <- -> 10.1.226.40 10191 [10.1.224.5 53]
age 122 use 0 sumd 0xef3/0xef3 pr 17 bkt 11118/14978 flags 2 drop 0/0
ifp hme0 bytes 528 pkts 2 e227
MAP 10.0.0.2 64256 <- -> 10.1.226.40 10188 [10.1.224.5 53]
age 51 use 0 sumd 0xef3/0xef3 pr 17 bkt 11115/14975 flags 2 drop 0/0
ifp hme0 bytes 181 pkts 2 e227
MAP 10.0.0.2 64255 <- -> 10.1.226.40 10187 [10.1.224.5 53]
age 51 use 0 sumd 0xef3/0xef3 pr 17 bkt 11114/14974 flags 2 drop 0/0
ifp hme0 bytes 259 pkts 2 e227
MAP 10.0.0.2 63157 <- -> 10.1.226.40 10065 [64.28.114.60 4700]
age 863411 use 0 sumd 0x12c3/0x12c3 pr 6 bkt 1443/6279 flags 1 drop 0/0
ifp hme0 bytes 27150 pkts 79 e227
MAP 10.0.0.2 63153 <- -> 10.1.226.40 10059 [17.250.248.64 993]
age 847778 use 0 sumd 0x12c1/0x12c1 pr 6 bkt 8827/13661 flags 1 drop 0/0
ifp hme0 bytes 6707 pkts 40 e227
MAP 10.0.0.2 63150 <- -> 10.1.226.40 10056 [64.81.102.240 993]
age 863778 use 0 sumd 0x12c1/0x12c1 pr 6 bkt 12279/730 flags 1 drop 0/0
ifp hme0 bytes 70261 pkts 349 e227
MAP 10.0.0.2 63147 <- -> 10.1.226.40 10053 [64.81.102.240 993]
age 863778 use 0 sumd 0x12c1/0x12c1 pr 6 bkt 12276/727 flags 1 drop 0/0
ifp hme0 bytes 355202 pkts 651 e227
MAP 10.0.0.2 63144 <- -> 10.1.226.40 10050 [17.250.248.64 993]
age 863781 use 0 sumd 0x12c1/0x12c1 pr 6 bkt 8818/13652 flags 1 drop 0/0
ifp hme0 bytes 285909 pkts 742 e227
MAP 10.0.0.2 63133 <- -> 10.1.226.40 10042 [192.18.104.13 993]
age 847775 use 0 sumd 0x12c4/0x12c4 pr 6 bkt 11327/16164 flags 1 drop 0/0
ifp hme0 bytes 81389 pkts 116 e227
MAP 10.0.0.2 63126 <- -> 10.1.226.40 10029 [192.18.104.13 993]
age 847782 use 0 sumd 0x12be/0x12be pr 6 bkt 11320/16151 flags 1 drop 0/0
ifp hme0 bytes 263735 pkts 272 e227
MAP 10.0.0.2 63123 <- -> 10.1.226.40 10026 [192.18.104.13 993]
age 863796 use 0 sumd 0x12be/0x12be pr 6 bkt 11317/16148 flags 1 drop 0/0
ifp hme0 bytes 791163 pkts 1065 e227
MAP 10.0.0.2 63114 <- -> 10.1.226.40 10016 [205.188.8.175 5190]
age 863926 use 0 sumd 0x12bd/0x12bd pr 6 bkt 11896/343 flags 1 drop 0/0
ifp hme0 bytes 18946 pkts 346 e227
MAP 10.0.0.2 63112 <- -> 10.1.226.40 10013 [207.182.190.28 5223]
age 863909 use 0 sumd 0x12bc/0x12bc pr 6 bkt 2971/7800 flags 1 drop 0/0
ifp hme0 bytes 35677 pkts 353 e227
MAP 10.0.0.2 63111 <- -> 10.1.226.40 10012 [192.18.104.18 5223]
age 863912 use 0 sumd 0x12bc/0x12bc pr 6 bkt 15540/3986 flags 1 drop 0/0
ifp hme0 bytes 59873 pkts 412 e227
MAP 10.0.0.2 50691 <- -> 10.1.226.40 10002 [216.155.193.174 5050]
age 863217 use 0 sumd 0x4336/0x4336 pr 6 bkt 4066/4922 flags 1 drop 0/0
ifp hme0 bytes 92469 pkts 827 e227
List of active host mappings:
10.0.0.2 -> 0.0.0.0 (use = 23 hv = 4100)
bash-2.05#
