I'm running openwrt on x86 hardware (two embedded network cards)
eth0 : lan
eth1: wan
I've created a new vlan interface on eth0 (eth0.100) vlan id 100
this is /etc/config/network :
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config interface 'wan'
option ifname 'eth1'
option proto 'dhcp'
option delegate '0'
option peerdns '0'
list dns '9.9.9.9'
config interface 'lan'
option ifname 'eth0'
option proto 'static'
list ipaddr '192.168.1.250/24'
option delegate '0'
config device
option type '8021q'
option ifname 'eth0'
option vid '100'
option name 'eth0.100'
config interface 'vlan100'
option ifname 'eth0.100'
option proto 'static'
option delegate '0'
list ipaddr '10.10.100.1/24'
I'm a connecting a client pc whose network card is setup on VLAN 100 to eth0. The client pc have ip 10.10.100.103. Naturally, I can ping openwrt on his vlan100 interface 10.10.100.1, but here is the problem, I can ALSO ping the eth0 ip 192.168.1.250 which I DO NOT WANT.
I believe its' because of defaut routing added by openwrt :
Destination Gateway Genmask Flags Metric Ref Use Iface
10.10.100.0 * 255.255.255.0 U 0 0 0 eth0.100
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
I've tried adding firewall rules to stop accessing eth0 network from eth0.100, but nothing seem's to stop accessing router's eth0 ip (192.168.1.250) from 10.10.100.0/24
That's normal. When allowing input to the router in the firewall then you allow input to any of the router's IP addresses. But that shouldn't be a problem.
that's a problem for me because I don't want users in the vlan (10.10.100.0/24) accessing services on the router lan ip (192.168.1.250).
So your basically saying that I can't block them ?
Set "input" of the vlan100 zone to reject or drop. That should stop the devices in the zone from accessing IP addresses of the router unless you explicitly allow it in a firewall rule.
Please copy the output of the following commands and post it here using the "Preformatted text </> " button:
Remember to redact passwords, MAC addresses and any public IP addresses you may have
ubus call system board; \
uci export network; \
uci export dhcp; uci export firewall; \
head -n -0 /etc/firewall.user; \
iptables-save -c; ip6tables-save -c; \
ip -4 addr ; ip -4 ro li tab all ; ip -4 ru;
iptables-save haven't been included coz there is too much sensitive infos to edit
root@OpenWrt:~# ubus call system board
{
"kernel": "4.14.171",
"hostname": "OpenWrt",
"system": "Intel(R) Celeron(R) N4100 CPU @ 1.10GHz",
"model": "ZOTAC ZBOX-CI329NANO",
"board_name": "zotac-zbox-ci329nano",
"release": {
"distribution": "OpenWrt",
"version": "19.07.2",
"revision": "r10947-65030d81f3",
"target": "x86/64",
"description": "OpenWrt 19.07.2 r10947-65030d81f3"
}
}
#########################################################
root@OpenWrt:~# uci export network
package network
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'xxxx:xxxx:xxxx::/48'
config interface 'lan'
option ifname 'eth0'
option proto 'static'
list ipaddr '192.168.1.250/24'
option delegate '0'
config interface 'wan'
option ifname 'eth1'
option proto 'dhcp'
option delegate '0'
option peerdns '0'
list dns '9.9.9.9'
config device
option type '8021q'
option ifname 'eth0'
option vid '100'
option name 'eth0.100'
config interface 'vlan100'
option ifname 'eth0.100'
option proto 'static'
option delegate '0'
list ipaddr '10.10.100.1/24'
#################################################
root@OpenWrt:~# uci export dhcp
package dhcp
config dnsmasq
option domainneeded '1'
option localise_queries '1'
option rebind_protection '1'
option rebind_localhost '1'
option local '/ici/'
option domain 'ici'
option expandhosts '1'
option readethers '1'
option leasefile '/tmp/dhcp.leases'
option resolvfile '/tmp/resolv.conf.auto'
option localservice '1'
option filterwin2k '1'
option cachesize '1500'
list notinterface 'wan'
list notinterface 'eth1'
list interface 'lan'
list interface 'vlan100'
config dhcp 'lan'
option interface 'lan'
option ignore '1'
config dhcp 'wan'
option interface 'wan'
option ignore '1'
config odhcpd 'odhcpd'
option maindhcp '0'
option leasefile '/tmp/hosts/odhcpd'
option leasetrigger '/usr/sbin/odhcpd-update'
option loglevel '4'
config domain
#####################################################
root@OpenWrt:~# uci export firewall
package firewall
config rule
option name 'Allow-DHCP-Renew'
option src 'wan'
option proto 'udp'
option dest_port '68'
option target 'ACCEPT'
option family 'ipv4'
option src_ip 'xx.xx.xx.xx'
config defaults
option syn_flood '1'
option output 'ACCEPT'
option forward 'REJECT'
option drop_invalid '1'
option input 'ACCEPT'
config zone
option network 'vlan100'
option forward 'REJECT'
option name 'vlan100'
list device 'eth0.100'
option output 'ACCEPT'
option input 'REJECT'
config zone
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'
option network 'lan LAN2'
list device 'eth0'
config include
option path '/etc/firewall.user'
config zone
option name 'wan'
option output 'ACCEPT'
option forward 'REJECT'
option masq '1'
option input 'DROP'
option network 'wan'
option mtu_fix '1'
##########################################################
root@OpenWrt:~# head -n -0 /etc/firewall.user
# This file is interpreted as shell script.
# Put your custom iptables rules here, they will
# be executed with each firewall (re-)start.
# Internal uci firewall chains are flushed and recreated on reload, so
# put custom rules into the root chains e.g. INPUT or FORWARD or into the
# special user chains, e.g. input_wan_rule or postrouting_lan_rule.
##########################################################
root@OpenWrt:~# ip -4 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
inet 192.168.1.250/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
inet x.x.x.x/24 brd x.x.x.x scope global eth1
valid_lft forever preferred_lft forever
13: eth0.100@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
inet 10.10.100.1/24 brd 10.10.100.255 scope global eth0.100
valid_lft forever preferred_lft forever
#############################################################
root@OpenWrt:~# ip -4 ro li tab all
default via x.x.x.x dev eth1 proto static src x.x.x.x
10.10.100.0/24 dev eth0.100 proto kernel scope link src 10.10.100.1
x.x.x.x/24 dev eth1 proto kernel scope link src x.x.x.x
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.250
broadcast 10.10.100.0 dev eth0.100 table local proto kernel scope link src 10.10.100.1
local 10.10.100.1 dev eth0.100 table local proto kernel scope host src 10.10.100.1
broadcast 10.10.100.255 dev eth0.100 table local proto kernel scope link src 10.10.100.1
broadcast x.x.x.x dev eth1 table local proto kernel scope link src x.x.x.x
local x.x.x.x dev eth1 table local proto kernel scope host src x.x.x.x
broadcast x.x.x.255 dev eth1 table local proto kernel scope link src x.x.x.x
broadcast 127.0.0.0 dev lo table local proto kernel scope link src 127.0.0.1
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1
broadcast 192.168.1.0 dev eth0 table local proto kernel scope link src 192.168.1.250
local 192.168.1.250 dev eth0 table local proto kernel scope host src 192.168.1.250
broadcast 192.168.1.255 dev eth0 table local proto kernel scope link src 192.168.1.250
###############################################################
root@OpenWrt:~# ip -4 ru
0: from all lookup local
32766: from all lookup main
32767: from all lookup default