CooCooCaChoo
Senior Member
Second sentence screams hacked. If you don't ever visit sites based in China, you could setup iptables to block the entire country see if that will stop the cams from calling home.
#!/bin/sh
nano firewall-start
./firewall-start
iptables -L | grep DROP
I would assign the cameras a static IP and set their default gateway to an inexistant address. This would prevent any access outside the lan
Some IP cams are P2P which means videostreams can only be viewed through the manufacturers P2P (cloud) service.
I wonder if the OP can use the firewall menu - network services filter tab to block the camera from the WAN. It looks like it should work. Need to keep it simple for him since he has no experience with SSH and Linux command line. I can try and test with it tomorrow or Monday.
My firewall is configured to restrict the IP cameras in the following ways:
- Block outbound Internet access.
- Allow outbound access to VPN interface only.
- Block all DNS requests.
- Allow NTP request to the router only.
The method I outlined with the iptables command should work as I use it on a router installed at a children's home. Devices can connect to the router LAN and they get a valid IP address. They just can't get out to the WAN. There are some articles on the web about ssh into asus router. You could also do a telnet session instead. dd-wrt does have a feature through the web GUI where you can enter firewall rules. But with asus, you will need telnet or ssh sessions to do this.Thanks for the info...anyway you can elaborate on your specific fw settings that you have in place that handles all this for you?
If you're going to be blocking the Internet for an IP camera, you probably want an local NTP server, so the timestamp in the video stream is accurate. Also, you'll maybe want to give computers on the local network and/or VPN, access to the IP camera. This is not what I have in place, it's just an example. Think about it.anyway you can elaborate?
#!/bin/sh
###############################################################################
# lockdown the device (192.168.1.222), but allow access from VPN only
/usr/sbin/iptables -I FORWARD -i br0 -s 192.168.1.222 -j DROP
/usr/sbin/iptables -I FORWARD -i br0 -o tun21 -s 192.168.1.222 -m state --state RELATED,ESTABLISHED -j ACCEPT
/usr/sbin/iptables -I INPUT -i br0 -s 192.168.1.222 -j DROP
/usr/sbin/iptables -I INPUT -i br0 -s 192.168.1.222 -p udp -m multiport --dports 53,67,68,123 -j ACCEPT
/usr/sbin/iptables -t nat -I PREROUTING -i br0 -s 192.168.1.222 -p udp -m multiport --dports 53,123 -j DNAT --to-destination 192.168.1.1
###############################################################################
#!/bin/sh
###############################################################################
# wait for system clock to be synchronized, then start NTP server
while [ "$(nvram get ntp_ready)" != "1" ]; do
/usr/bin/logger -t $(/usr/bin/basename $0) "custom script waiting for system clock to be synchronized [$$]"
/bin/sleep 1
done
[ "$(nvram get ntp_ready)" == "1" ] && [ -z "$(/bin/pidof ntpd)" ] && /usr/sbin/ntpd -I br0 -dd
###############################################################################
The method I outlined with the iptables command should work as I use it on a router installed at a children's home. Devices can connect to the router LAN and they get a valid IP address. They just can't get out to the WAN. There are some articles on the web about ssh into asus router. You could also do a telnet session instead. dd-wrt does have a feature through the web GUI where you can enter firewall rules. But with asus, you will need telnet or ssh sessions to do this.
Edit: you can create a free opendns.com account and use it as your DNS servers to filter Web sites, blacklist and white list sites. But not sure if you can use IP address. I use the service on two sites bit only black list bu URL website name.
Code:#!/bin/sh iptables -I FORWARD -s 192.168.5.189 -j DROP
2. Is this still going to allow VPN connection to view IP cam with me dropping outbound?
iptables -I FORWARD -s 192.168.5.189 -i br0 ! -o tun2+ -j DROP
iptables -I FORWARD -i br0 -o $(nvram get wan0_ifname) -p udp -m udp --dport 123 -j ACCEPT
Thank you, I fixed it. I was copying straight from my router, sorry. That piece you cannot do because it requires one to set the router clock in a non-standard way. Such as: (1) have the router get its time from a computer on your local network, or (2) special hardware tricks to set the router's clock.@Fitz Mutch Wouldn't the wan-start be on an infinite wait during router boot due to the dnsmasq.conf.add entry?
address=/.pool.ntp.org/ntp.ubuntu.com/.timefreq.bldrdoc.gov/time.nist.gov/time-nw.nist.gov/time-a.nist.gov/time-b.nist.gov/time-c.nist.gov/time-d.nist.gov/time.windows.com/tick.usno.navy.mil/tock.usno.navy.mil/ntp.usno.navy.mil/ntp2.usno.navy.mil/tick.usnogps.navy.mil/tock.usnogps.navy.mil/ntp.rokutime.com/192.168.1.1
Can anyone link to a guide for the Asus routers (I have the AC-88U) for building firewall rules from scratch?
So I'd really like to set up some firewall rules for my six cameras to block all outbound access (though leave them open and accessible to my VPN connection)
CAMERAS 192.168.1.196, 192.168.1.15-192.168.1.20, 192.168.1.50:192.168.1.55
/jffs/scripts/IPCamsBlock.sh init
No, you will need to use a rule like
Code:iptables -I FORWARD -s 192.168.5.189 -i br0 ! -o tun2+ -j DROP
So any camera traffic that needs to go back out through either of the VPN servers (because you connected inbound to one of the servers) will be ALLOWED.
However, this rule will BLOCK everything outbound via the WAN, including the NTP port, so if you want your cameras to get their time from the internet you will need another rule:
Code:iptables -I FORWARD -i br0 -o $(nvram get wan0_ifname) -p udp -m udp --dport 123 -j ACCEPT
You must initially set up SSH access to the router via the GUI, then start a session using PuTTY (although XShell is highly recommended) then if you can cut'n'paste into an editor then you should be good to go.
If you are using Windows then WinSCP is (in my view) an essential tool for expanding the capabilties of the router using scripts. You can move around the router file system, viewing, editing, etc. and even create backup copies of your scripts using drag'n'drop between a windows folder and the router.
You can even execute/test your scripts from within WinSCP by simply right clicking on the script in the GUI.
Anyway, I wrote a script for my family/colleagues who also have the same security concerns. So as shown in the script help, you simply only need to create/maintain a text file containing one line defining the I/P addresses of your cameras...
e.g. say you have 13 cameras to be blocked from accessing the Internet but still remain accessible for remote viewing over the VPN.
/jffs/configs/IPGroups
Code:CAMERAS 192.168.1.196, 192.168.1.15-192.168.1.20, 192.168.1.50:192.168.1.55
/jffs/scripts/IPCamBlock.sh
#!/bin/sh
#=====================================================================================================================
#
# Block unsolicited outbound traffic from the I/P cameras, except for NTP, but still allow viewing via the VPN Servers
#
# IPCamsBlock [help|-h] | [init] | [status]
#
# IPCamsBlock init
# Create the blocking rules (usually called from /jffs/scripts/firewall-start)
# (Assumes /jffs/configs/IPGroups exists with valid 'CAMERAS' entry - Uppercase text!)
# e.g. CAMERAS 10.88.8.10,10.88.8.15-10.88.8.20,10.88.8.50:10.88.8.55
# IPCamsBlock
# Show status of the rules in name form e.g. CAM-L-F1812
# IPCamsBlock status
# Show status of the rules in I/P form e.g. 10.88.8.10
#
#
# /jffs/scripts/firewall-start
# /jffs/scripts/IPCamsBlock.sh init
#*************************************FUNCTIONS***************************************************************
P.S. It is considered good practice to keep custom scripts separate and call them from the system scripts as necessary rather than copy all the code in say an existing 'firewall-start' script!
So you would simply add the call to run '/jffs/scripts/IPCamBlock.sh' from 'firewall-start' by adding the line
Code:/jffs/scripts/IPCamsBlock.sh init
Then if anything goes wrong, you can just disable 'IPCamBlock.sh' rather than inadvertently breaking 'firewall-start'.
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!