在我的办公室里,所有人都在使用 Facebook 和其他一些我们不想使用的网站。形成服务器PC,我曾经通过/ect/rc.local文件共享我的网络。我用这一行编辑了文件:
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -F
iptables -X
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
iptables -A INPUT -j ACCEPT
iptables -A OUTPUT -j ACCEPT
iptables -A FORWARD -j ACCEPT
iptables -t nat -A POSTROUTING -o eth+ -j MASQUERADE
Run Code Online (Sandbox Code Playgroud)
这样我的网络就被所有人共享了。要进行过滤以便没有人可以访问 Facebook,我修改rc.local file并添加了这两行:
iptables -I INPUT 1 -s facebook.com -j DROP
iptables -I INPUT 2 -d facebook.com -j DROP
Run Code Online (Sandbox Code Playgroud)
我的/etc/rc.local文件现在是这样的:
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -I INPUT 1 -s facebook.com -j DROP
iptables -I INPUT 2 -d facebook.com -j DROP
iptables -F
iptables -X
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
iptables -A INPUT -j ACCEPT
iptables -A OUTPUT -j ACCEPT
iptables -A FORWARD -j ACCEPT
iptables -t nat -A POSTROUTING -o eth+ -j MASQUERADE
Run Code Online (Sandbox Code Playgroud)
但是服务器还不能阻止所有 pc 的 facebook 访问。任何人都可以告诉我如何阻止我的服务器对facebook的所有访问
gro*_*wse 18
此问题的任何技术解决方案都无法解决实际问题,即您办公室里的人很无聊,想浏览 facebook / 看色情内容 / 随便什么而不是工作。
这是一个管理问题,需要通过使用管理工具来解决,例如明确的企业可接受的互联网使用政策,详细说明什么是可接受的,什么是不可接受的,以及如果它们被破坏会发生什么。如果一个人整天都在使用 facebook 而不是做他的工作,不要阻止 facebook,解雇他的屁股*。
*尽管有司法/当地法律环境和限制。
这真是一个狡猾的地方。如果没有大量资源、专业知识和控制,您就无法有效地审查互联网。最终会发生的事情是您将实施某种黑客行为(您的iptables帖子表明您可能不具备执行此操作所需的所有专业知识),您的用户将解决它,现在您有一个愤怒的老板要求知道为什么你不能正确地完成你的工作。
您需要与您的管理层设定期望,尽管您可以根据您拥有的资源和技能实施某些事情,但它可能不会有效,因此会浪费您的时间。