Allow only 1 ip address

i using linksys e1200 with openwrt. i set the router to static ip and i am using mac address filter .
now can i use IP filter by implement iptables rules ?

i thought about something like this
this will work ?

iptables -P FORWARD 192.168.1.5 -j ACCEPT
iptables -A INPUT -s 192.168.1.5 -j ACCEPT
iptables -A OUTPUT -d 192.168.1.5 -j ACCEPT
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

No. These rules will lock you out from internet.
The INPUT chain is for incoming connections from internet to lan.
The OUTPUT chain is for outgoing connection from lan to internet

iptables -A INPUT -d 192.168.1.5 -j ACCEPT
iptables -A OUTPUT -s 192.168.1.5 -j ACCEPT

will work

However I am not sure about this one:

iptables -P FORWARD -d 192.168.1.5 -j ACCEPT

Please also check first the iptables -L command before typing any of the commands.
These rules should be before your default drop rule. Use iptables insert command to insert them into the table. The -A is append and it appends the rule as last in the table.

  • That method leads to collision with default firewall service.
  • The first rule is incorrect.
  • DHCP, DNS, NTP and package management are broken.
  • IPv6-connectivity is ignored.
2 Likes
  • Why can't you use the built-in firewall?
  • You can make drop forward and input rules for devices that do not equal IP 192.168.1.5
2 Likes

The INPUT handles connections from any interface to the device itself. Likewise the OUTPUT handles egress traffic originating from the device. All transit traffic from one interface to another (or zone if you prefer) is handled in FORWARD.