Firewall does not work?

Hello,

I've got public IP from ISP and currently it's assigned on my openwrt on wanb (lan1) interface, so I started wondering if firewall is set up correctly and it seems like it's not. The only open port should be 1194/udp for openvpn server - that works from internet as I tested it, but nmap does not show it open, instead it shows these port as open, why?

53/tcp
80/tcp
443/tcp
53/udp

Here's my /etc/config/firewall

config defaults
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'REJECT'
	option synflood_protect '1'

config zone
	option name 'lan'
	option input 'ACCEPT'
	option output 'ACCEPT'
	option forward 'ACCEPT'
	list network 'lan'

config zone
	option name 'wan'
	option input 'REJECT'
	option output 'ACCEPT'
	option forward 'REJECT'
	option masq '1'
	option mtu_fix '1'
	list network 'wan'
	list network 'wanb'

config forwarding
	option src 'lan'
	option dest 'wan'

config rule
	option name 'Allow-DHCP-Renew'
	option src 'wan'
	option proto 'udp'
	option dest_port '68'
	option target 'ACCEPT'
	option family 'ipv4'

config rule
	option name 'Allow-Ping'
	option src 'wan'
	option proto 'icmp'
	option icmp_type 'echo-request'
	option family 'ipv4'
	option target 'ACCEPT'

config rule
	option name 'Allow-IGMP'
	option src 'wan'
	option proto 'igmp'
	option family 'ipv4'
	option target 'ACCEPT'

config rule
	option name 'Allow-IPSec-ESP'
	option src 'wan'
	option dest 'lan'
	option proto 'esp'
	option target 'ACCEPT'
	option family 'ipv4'

config rule
	option name 'Allow-ISAKMP'
	option src 'wan'
	option dest 'lan'
	option dest_port '500'
	option proto 'udp'
	option target 'ACCEPT'
	option family 'ipv4'

config rule
	option name 'Block-Public-DNS'
	option src 'lan'
	option dest 'wan'
	option target 'REJECT'
	list proto 'tcp'
	list proto 'udp'
	option dest_port '53'
	option family 'ipv4'
	option enabled '0'

config include
	option path '/etc/firewall.user'

config redirect
	option dest_port '53'
	option name 'Force DNS'
	option src_dport '53'
	option target 'DNAT'
	option src 'lan'
	option dest 'lan'
	option dest_ip '10.0.0.1'

config redirect
	option target 'DNAT'
	option name 'vpn_nas'
	list proto 'udp'
	option src 'wan'
	option src_dport '1194'
	option dest 'lan'
	option dest_ip '10.0.0.100'
	option dest_port '1194'

Thank you

where from did you run nmap ?

2 Likes

Yeah, you got a point, I ran it from LAN, but my outgoing connection goes via wan, not wanb (public ip), so I thought it's okay, but it wasn't. I connected my laptop via mobile internet to do a scan again and output is different, but still doesn't look as expected. Nothing except 1194/udp should be opened, why does it not show as open and other ports are? I used "nmap -sS -sU -T4 -A -v publicipadress"

Not shown: 998 closed tcp ports (reset), 984 closed udp ports (port-unreach)
PORT      STATE         SERVICE      VERSION
21/tcp    open          tcpwrapped
1720/tcp  open          h323q931?
67/udp    open|filtered dhcps
767/udp   open|filtered phonebook
1031/udp  open|filtered iad2
1719/udp  open|filtered h323gatestat
2222/udp  open|filtered msantipiracy
3052/udp  open|filtered apc-3052
6050/udp  open|filtered x11
17207/udp open|filtered unknown
17888/udp open|filtered unknown
18980/udp open|filtered unknown
19096/udp open|filtered unknown
34125/udp open|filtered unknown
41702/udp open|filtered unknown
42313/udp open|filtered unknown
48078/udp open|filtered unknown
49194/udp open|filtered unknown

does it have any relation, connection wise, with the router ?
or did you just share internet with your laptop from the phone, via wifi ?

1 Like

Nmap has its own big manual and a known weakness/feature according to their own manual that makes it sniffing 360° on every device it goes trough and report false results all the way to the target.
This is mostly because the actual hardware from everywhere responds to the actual sniffing since sniffing isn’t IP controlled but broadcast all over the data line.

The only way to minimize this is to connect the sniffing computer directly to the port of the device you want to sniff.

We have a lot of these forum treads already!

It would also make sense to check that your network configuration is correct.

Please copy the output of the following commands and post it here using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have:

cat /etc/config/network

Well, it might be related as the second wan is actually a copy of mobile sim in a router. My friend tried to do the same scan from his house and result was that NONE of the ports were open, neither openvpn port..

Gotcha, thanks for info.

config interface 'loopback'
	option device 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'

config device
	option name 'br-lan'
	option type 'bridge'
	option ipv6 '0'
	list ports 'lan2'
	list ports 'lan3'
	list ports 'lan4'

config interface 'lan'
	option proto 'static'
	option netmask '255.255.255.0'
	option ipaddr '10.0.0.1'
	option delegate '0'
	option broadcast '10.0.0.255'
	list dns '10.0.0.1'
	option device 'br-lan'

config device
	option name 'wan'
	option macaddr 'MACADDR'
	option ipv6 '0'

config interface 'wan'
	option device 'wan'
	option proto 'dhcp'
	list dns '10.0.0.1'
	option peerdns '0'
	option hostname 'android'
	option delegate '0'
	option metric '30'

config interface 'wanb'
	option proto 'pppoe'
	option username 'USERNAME'
	option password 'PASSWORD'
	option peerdns '0'
	list dns '10.0.0.1'
	option metric '20'
	option delegate '0'
	option ipv6 '0'
	option device 'lan1'

config device
	option name 'eth0'
	option ipv6 '0'

config device
	option name 'lo'
	option ipv6 '0'

Looks okay there. You should be good!

1 Like

I thought nmap is one of the best scanners out there. So there's no way to scan using nmap to see if 1194 port is opened? I know it's opened, because I connected via vpn from different house/isp. Is there any better software/service to use or a specific nmap option in order to show it opened?

Thanks.

https://nmap.org/book/scan-methods-udp-scan.html

1 Like

Well nmap is actually little of a hype when you read the actual manual and many expect more and nicer looking result than it actually deliver.
It does ping and check what comes back, but it doesn’t know from where the answer came since the answer has no ID mark. It is only yes, no, maybe little or maybe more. Little like thunder alongside mountains, one lightning gives a lot of different booms from different mountains that reflects the first boom sound wave.

As like all other measuring systems it has its pros and cons but the technician measuring is responsible to know everything about measuring what he/she want to measure before measuring or else the measurement isn’t scientific.
Then it is just a value of some sort.

1194 is a port you have opened highly probable for OpenVPN, does it work or not?

If you want to know if it is closed you can turn on firewall logging on wan because then the scan robots looking for companies with OpenVPN to DoS with filtered registered port 1194 will be trapped.

And if you have the server running and port open you will sooner or later get errors from attempts to log in to the tunnel in the OpenVPN log.

I recommend right now to use another random choosed port other than 1194 that isn’t already used by the online scan robots. They know of all registered communications port already so choose a not registered port number.

I would say the wan firewall log is better than nmap because then you see how much shit is trying to come inside. What to look out for is bots trying high port numbers because cheap firewalls doesn’t necessarily block high port numbers. But OpenWRT does that.

What exactly are you trying to find out? You want a scanner to tell you if a port (which you already know is open because it's being used) is open? Why?

To know if the network is secure. I know 1194 is opened, but i can’t verify that using nmap, so I am not 100% sure it works in each case as intended. This weird behaviour might be limited to udp scanning only:

https://nmap.org/book/scan-methods-udp-scan.html

Table 5.3, “How Nmap interprets responses to a UDP probe” shows that the open|filtered state occurs when Nmap fails to receive any responses from its UDP probes to a particular port. Yet it also shows that, on rare occasions, the UDP service listening on a port will respond in kind, proving that the port is open. The reason these services don't respond often is that the empty packets Nmap sends are considered invalid.”

Is there any reason you suspect it wouldn't be? Have you disabled any of the default firewall rules or added traffic rules/port forwards that you don't need?

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.