- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- IPTABLES - deny hosts access to the internet
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2010 04:34 PM
02-13-2010 04:34 PM
The sytuation is as follows:
GATEWAY
^
|
|
ROUTER1
^
|
|
<----HOST_A 11:11:11:11:11:11
^
|
|
<----HOOST_B 22:22:22:22:22:22
The iptables is included in my routers firmware.
I need to allow to the internet only those hosts listed in IP tables. So if i include HOSTA_A MAC and HOSTS_B MAC address only those addresses are allowed to the internet.
iptables -P INPUT DROP
iptables -I INPUT -m mac ! --mac-source 11:11:11:11:11:11 -j ACCEPT
iptables -I INPUT -m mac ! --mac-source 22:22:22:22:22:22 -j ACCEPT
Now if I try to access the Internet from another device iptables cuts the access only to the ROUTER_1 but not to the Internet. I can still ping websites and the gateway.
Please help
Peter
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2010 07:53 PM
02-13-2010 07:53 PM
Re: IPTABLES - deny hosts access to the internet
Firewall on the gateway.
iptables -A INPUT
That will deny them access to the Internet.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2010 07:29 AM
02-14-2010 07:29 AM
Re: IPTABLES - deny hosts access to the internet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2010 04:17 AM
02-15-2010 04:17 AM
Re: IPTABLES - deny hosts access to the internet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2010 11:32 PM
02-15-2010 11:32 PM
SolutionThe "policy" (iptables -P) decides what to do with a packet if _none_ of the rules in the table match it. The rules are processed in order, and the first rule that matches the packet and provides a decision (e.g. -j ACCEPT or -j DROP) will determine the fate of the packet.
So, I'd prefer to avoid "double negatives" and instead would write the rules to directly spell out what I want:
iptables -P FORWARD DROP
iptables -I FORWARD -i
iptables -I FORWARD -m mac --mac-source 11:11:11:11:11:11 -j ACCEPT
iptables -I FORWARD -m mac --mac-source 22:22:22:22:22:22 -j ACCEPT
Replace
The above ruleset allows in anything that comes in from the gateway, which may not be the safest choice.
If you don't need the ability to access your internal network from the outside, you might want to use state matching:
iptables -P FORWARD DROP
iptables -I FORWARD -i
iptables -I FORWARD -m mac --mac-source 11:11:11:11:11:11 -j ACCEPT
iptables -I FORWARD -m mac --mac-source 22:22:22:22:22:22 -j ACCEPT
With this, anything from your two chosen hosts may go out, but only responses to connections already established from the inside may come in. This will keep much of the "scum of the Internet" (= malware programs and script kiddies seeking vulnerable hosts) out of your internal network, making it a safer place.
If you later need to accept incoming traffic by specific protocols, you can do it by adding specific ACCEPT rules for those protocols and/or destination hosts.
MK