How to prevent a device on my router from accessing the Internet?

3

I'm thinking of setting up a local server on an old machine I have lying around. So that I can easily ssh into it, I would like to add it to my current network by plugging it right into my router. Currently, all my other devices access the Internet via this router, but I would like to restrict this in my server's case.

Is this something that I can set up right in the router? Or is it operating system specific (I should mention I will be virtualizing my server so it can live beside other VMs, all of them Linux)?

n0pe

Posted 2011-08-25T02:35:46.990

Reputation: 14 506

I'm not clear on what you're getting at. Are you trying to prevent your server from accessing the internet? – digitxp – 2011-08-25T02:38:54.333

Yes that's exactly what I'm trying to do. However, other devices should still be able to access the net. – n0pe – 2011-08-25T02:40:08.763

1You could just not give it a default gateway in the IP configuration. That would prevent it from accessing the internet. – bfhd – 2011-08-25T03:13:51.563

Answers

5

Modified from this Server Fault question:

#Flush existing rules
iptables -F
# Set up default DROP rule for eth0
iptables -P INPUT DROP
# Allow existing connections to continue
iptables -A INPUT -i eth0 -m state EXISTING,RELATED -j ACCEPT
# Accept everything from the 192.168.1.x network
iptables -A INPUT -i eth0 -s 192.168.1.0/24 -j ACCEPT
# Allow connections from this host to 192.168.2.10
iptables -A OUTPUT -o eth0 -s 192.168.1.0/24 -j ACCEPT

digitxp

Posted 2011-08-25T02:35:46.990

Reputation: 13 502

1iptables rules. – digitxp – 2011-08-25T02:53:51.667

0

This can be acheived on most commercial home routers, as well as the OS. Just check out your routers manual.

Keltari

Posted 2011-08-25T02:35:46.990

Reputation: 57 019