This is the first time I am learning to connect two routers to route with each other. To keep everything simple, I want the same setup on the two routers, such that:
To resolve IP by hostnames, like iphone.lan1, desktop.lan2, etc.
Allow all local clients to ping all device, local or remote.
Allow some local clients to access Luci on the remote router
Allow some local clients ssh to some remote clients
When Firewall is not running on both router, I can do 1 & 2, and ssh are open to all also.
Please help me on how to setup the Firewalls to make this work.
the one your clients will access.
the two are possible if routeur need them also.
in preference order.
you can also specify in dhcp advanced options of LAN1 these dns configs :
6,IPofDNSofLAN1
15,lan1
then clients will get forced on these parameters.
same for LAN2.
This should be applied to the R1 starting from factory defaults:
uci -q delete network.lan_lan
uci set network.lan_lan="route"
uci set network.lan_lan.interface="wan"
uci set network.lan_lan.target="192.168.102.0/24"
uci set network.lan_lan.gateway="10.1.0.2"
uci commit network
/etc/init.d/network restart
uci set dhcp.@dnsmasq[0].localservice="0"
uci add_list dhcp.@dnsmasq[0].server="/lan2/10.1.0.2"
uci commit dhcp
/etc/init.d/dnsmasq restart
uci add_list firewall.@zone[1].masq_dest="!10.1.0.2/32"
uci add_list firewall.@zone[1].masq_dest="!192.168.102.0/24"
uci -q delete firewall.wan_dns
uci set firewall.wan_dns="rule"
uci set firewall.wan_dns.name="Allow-DNS-WAN"
uci set firewall.wan_dns.src="wan"
uci add_list firewall.wan_dns.src_ip="10.1.0.2/32"
uci add_list firewall.wan_dns.src_ip="192.168.102.0/24"
uci set firewall.wan_dns.dest_port="53"
uci set firewall.wan_dns.proto="tcp udp"
uci set firewall.wan_dns.target="ACCEPT"
uci -q delete firewall.wan_admin
uci set firewall.wan_admin="rule"
uci set firewall.wan_admin.name="Allow-Admin-WAN"
uci set firewall.wan_admin.src="wan"
uci set firewall.wan_admin.src_ip="192.168.102.0/24"
uci set firewall.wan_admin.dest_port="22 80 443"
uci set firewall.wan_admin.proto="tcp"
uci set firewall.wan_admin.target="ACCEPT"
uci -q delete firewall.l2l_icmp
uci set firewall.l2l_icmp="rule"
uci set firewall.l2l_icmp.name="Allow-ICMP-Forward"
uci set firewall.l2l_icmp.src="wan"
uci set firewall.l2l_icmp.src_ip="192.168.102.0/24"
uci set firewall.l2l_icmp.dest="lan"
uci set firewall.l2l_icmp.proto="icmp"
uci set firewall.l2l_icmp.icmp_type="echo-request"
uci set firewall.l2l_icmp.family="ipv4"
uci set firewall.l2l_icmp.target="ACCEPT"
uci -q delete firewall.l2l_ssh
uci set firewall.l2l_ssh="rule"
uci set firewall.l2l_ssh.name="Allow-SSH-Forward"
uci set firewall.l2l_ssh.src="wan"
uci set firewall.l2l_ssh.src_ip="192.168.102.0/24"
uci set firewall.l2l_ssh.dest="lan"
uci set firewall.l2l_ssh.dest_port="22"
uci set firewall.l2l_ssh.proto="tcp"
uci set firewall.l2l_ssh.target="ACCEPT"
uci commit firewall
/etc/init.d/firewall restart
I can have two options for the hostname resolving to work:
Use DHCP options to tell each client which DNS to use for the corresponding domain, lan1/lan2, etc.
Local Client will only talk to the local DNS, and the local DNS will find out the correct IP and reply back. In this case, I can have a Firewall Rule restrict DNS query to local DNS only.
The local DNS will cache resolution, but will need to talk with the other DNS.
The clients may also need to talk to a "slave" DNS (as secondary) if the primary do not answer.
DHCP options (in advanced options of DHCP of the LAN) is just a "forced" method to push parameters to clients.
These forced options may not be necessary with the firewall rules given by @vgaetera
The relevant interface name is p2p and you can attach it to the wan zone.
Or create a separate zone with disabled masquerading.
But then you need to adjust the firewall rules.
I replicated the settings, via Luci, to the two routers that connected the the ISP switch. And they work flawlessly with your config.
When reading Internet posts / articles, I know it is needed to disable NAT for routed destinations, but never sure where to put it and the correct syntax. Now I know I can use '!' in front of a subnet to exclude it.
Hi @sampson
I have been working quite some time to setup a similar connection as you are, and I had a lot of similar issues. @vgaetera & @krazeh have been a tremendous help.
If this can help here is a link to my installation
Actually as I already planned to install this between 2 sites in different countries, I did setup all the encryption from the right beginning. WireGuard on top of OpenWrt has been the solution.
As when it will be installed I will not be able to easily access both sites at the same time, I did also setup another access through my iPhone form anywhere in the internet. So in case something goes wrong in my Site-2-Site I can still access both routers.
Have fun & it is very educational project. I'll keep a look on your DNS aspect as this is a point I haven't solved yet...