I am trying to redirect packets from external ip (x.x.x.x) to internal ip (192.168.1.2). I watch packets how are pass and I see port unreachable.
If I make 192.168.1.2:8080 work fine but I change it to x.x.x.x:8080 does not work.
my pf.conf:
After I made some changes to sysctl :
I get this from wireshark:
Now I don't see port unreachable but I still can't reach my web server.
If I make 192.168.1.2:8080 work fine but I change it to x.x.x.x:8080 does not work.
Code:
11:47:18.837301 IP localhost.61777 > x.x.x.x.8080: Flags [S], seq 3896576648, win 65535, options [mss 1460,nop,wscale 3,sackOK,TS val 2647558 ecr 0], length 0
11:47:18.837716 IP x.x.x.x.8080 > localhost.61777: Flags [FR.], seq 0, ack 3896576649, win 0, length 0
11:47:18.839703 IP x.x.x.x > localhost: ICMP x.x.x.x tcp [B]port 8080 unreachable[/B], length 36
Code:
#***************************************************** var's
ext_if = "re0"
int_ip = "{192.168.1.0/24 ,127.0.0.1}"
tcp_services = "{http ,https ,ssh ,domain ,8080}"
udp_services = "{23399 ,domain}"
int_services = "{3306 ,8080}"
p2p_tcp = "{4662 ,4672}"
p2p_udp = "{4665}"
#***************************************************** options
set block-policy drop
set loginterface re0
set skip on lo0
#***************************************************** NAT
# aMule TCP and UDP
#rdr pass on egress proto tcp to port 4662 -> 192.168.1.2
#rdr pass on egress proto udp to port 4672 -> 192.168.1.2
#rdr pass on egress proto udp to port 4665 -> 192.168.1.2
# allow access from outside to web server,mysql
[B]rdr pass on $ext_if proto tcp from any to any port $int_services -> 192.168.1.2[/B]
# nat for vpn client
nat on $ext_if from 192.168.1.0/24 to any -> $ext_if
#***************************************************** Rules
# block in&out traffic
block drop in log(all) on $ext_if all
block drop out log(all ,user) on $ext_if all
#pass in on $ext_if proto tcp from any to any port 8080 rdr-to 192.168.1.2
# pass in tcp&udp traffic for some ports
pass in on $ext_if inet proto tcp from any port $tcp_services \
to any keep state
pass in on $ext_if inet proto udp from any port $udp_services \
to any keep state
[B]pass in on $ext_if inet proto tcp from any \
to any port $int_services keep state[/B]
pass in on $ext_if inet proto {tcp ,udp} from $int_ip port $int_services \
to $int_ip port $int_services keep state
# pass out tcp&udp traffic for some ports
pass out on $ext_if inet proto tcp from any to any port \
$tcp_services modulate state
pass out on $ext_if inet proto udp from any to any port \
$udp_services modulate state
# pass in and out p2p traffic
pass in on $ext_if inet proto tcp from any port $p2p_tcp \
to any no state
pass in on $ext_if inet proto udp from any port $p2p_udp \
to any no state
#pass out on $ext_if inet proto tcp from any port $p2p_tcp \
# to any keep state
#pass out on $ext_if inet proto udp from any to any port \
# $p2p_udp modulate state
# block nmap scan
#*********** XMASS SCAN **************#
#block drop in log(all) on $ext_if inet proto tcp from any \
# flags FUP/ to any
#block drop in log(all) on $ext_if inet proto tcp flags FUP/RA
#block drop in log(all) on $ext_if inet proto tcp flags FUP/
Code:
kern.smp.forward_signal_enabled: 1
net.inet.ip.forwarding: 1
net.inet.ip.fastforwarding: 1
Code:
12:05:32.698393 IP 0.0.0.0.52177 > x.x.x.x.8080: Flags [S], seq 2115572525, win 65535, options [mss 1460,nop,wscale 3,sackOK,TS val 3740233 ecr 0], length 0
12:05:35.700690 IP 0.0.0.0.52177 > x.x.x.x.8080: Flags [S], seq 2115572525, win 65535, options [mss 1460,nop,wscale 3,sackOK,TS val 3743233 ecr 0], length 0
12:05:38.904153 IP 0.0.0.0.52177 > x.x.x.x.8080: Flags [S], seq 2115572525, win 65535, options [mss 1460,nop,wscale 3,sackOK,TS val 3746433 ecr 0], length 0
12:05:39.440841 IP localhost.56766 > 66.249.92.104.http: Flags [F.], seq 980015912, ack 2092775662, win 8207, options [nop,nop,TS val 3746969 ecr 3071078567], length 0
12:05:39.586692 IP 66.249.92.104.http > localhost.56766: Flags [F.], seq 1, ack 1, win 227, options [nop,nop,TS val 3071196365 ecr 3746969], length 0
12:05:39.586777 IP localhost.56766 > 66.249.92.104.http: Flags [.], ack 2, win 8207, options [nop,nop,TS val 3747114 ecr 3071196365], length 0
12:05:42.107625 IP 0.0.0.0.52177 > x.x.x.x.8080: Flags [S], seq 2115572525, win 65535, options [mss 1460,sackOK,eol], length 0
12:05:45.311094 IP 0.0.0.0.52177 > x.x.x.x.8080: Flags [S], seq 2115572525, win 65535, options [mss 1460,sackOK,eol], length 0
12:05:48.514567 IP 0.0.0.0.52177 > x.x.x.x.8080: Flags [S], seq 2115572525, win 65535, options [mss 1460,sackOK,eol], length 0
12:05:54.721291 IP 0.0.0.0.52177 > x.x.x.x.8080: Flags [S], seq 2115572525, win 65535, options [mss 1460,sackOK,eol], length 0
12:05:59.867910 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from xx:xx:xx:xx:xx:xx (oui Unknown), length 300
12:06:06.876493 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from xx:xx:xx:xx:xx:xx (oui Unknown), length 300
12:06:06.934529 IP 0.0.0.0.52177 > x.x.x.x.8080: Flags [S], seq 2115572525, win 65535, options [mss 1460,sackOK,eol], length 0
12:06:14.886172 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from xx:xx:xx:xx:xx:xx (oui Unknown), length 300
12:06:27.901281 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from xx:xx:xx:xx:xx:xx (oui Unknown), length 300
12:06:31.160780 IP 0.0.0.0.52177 > x.x.x.x.8080: Flags [S], seq 2115572525, win 65535, options [mss 1460,sackOK,eol], length 0
12:06:47.925007 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from xx:xx:xx:xx:xx:xx (oui Unknown), length 300
12:06:49.798299 IP localhost.56725 > 192.168.1.1.domain: 16881+ A? www.stopbadware.org. (37)
12:06:49.961038 ARP, Request who-has localhost tell 192.168.1.1, length 46
12:06:49.961057 ARP, Reply localhost is-at xx:xx:xx:xx:xx:xx (oui Unknown), length 28
12:06:49.961061 IP 192.168.1.1.domain > localhost.56725: 16881 2/5/10 CNAME stopbadware.org., A 128.103.64.79 (386)
12:07:19.027050 IP 192.168.1.1 > ALL-SYSTEMS.MCAST.NET: igmp query v2