Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
04-24-2005, 02:09 PM
|
#1
|
Member
Registered: Feb 2005
Location: Ottawa/Montréal
Distribution: Slackware + Darwin (MacOS X)
Posts: 468
Rep:
|
iptables to block lan services (audit mine)
Relevant fragment of the startup rules (it's POLICY ACCEPT):
Code:
# Default redirect to gateway
iptables -t nat -A PREROUTING -p tcp -i wlan0 --dport 80 -j DNAT --to 10.0.0.1
iptables -t nat -A PREROUTING -p tcp -i wlan0 ! --dport 80 -j DROP
# Block all those sneaky LAN services
iptables -N LAN_BLOCK
iptables -t filter -A LAN_BLOCK -o wlan0 --match multiport --dport 25 -j DROP
iptables -t filter -A LAN_BLOCK -o wlan0 --match multiport --dport 24 -j DROP
iptables -t filter -A LAN_BLOCK -o wlan0 --match multiport --dport 23 -j DROP
iptables -t filter -A LAN_BLOCK -o wlan0--match multiport --dport 113 -j DROP
iptables -t filter -A LAN_BLOCK -o wlan0 --match multiport --dport 137:139 -j DROP
iptables -t filter -A LAN_BLOCK -o wlan0 --match multiport --dport 548 -j DROP
iptables -t filter -A LAN_BLOCK -o wlan0 --match multiport --dport 427 -j DROP
iptables -t filter -A LAN_BLOCK -o wlan0 --match multiport --dport 3689 -j DROP
iptables -t filter -A LAN_BLOCK -o wlan0 --match multiport --dport 8770 -j DROP
And the rule invoked to allow a certain IP address is
Code:
iptables -t nat -I PREROUTING -i wlan0 -s 10.0.0.19 -j LAN_BLOCK
I feel like I'm missing something from the LAN_BLOCK chain. I basically want all services not in LAN_BLOCK to pass through. Is there an ACCEPT or RETURN line I should add at the end?
This is the fruition of much  and reading on this forum, thanks everyone, this forum is great!
Last edited by michaelsanford; 04-24-2005 at 04:19 PM.
|
|
|
04-25-2005, 07:25 AM
|
#2
|
LQ Guru
Registered: Sep 2001
Location: Montreal, Canada
Distribution: Slackware; Debian; Gentoo...
Posts: 2,163
Rep:
|
hmmm nice rule there, but I think there is some mistakes.
I dont know --match multiport flag, are you sure this one is valid? Plus, you dont really need multiport if you block ports one by one like you do there.
Then, you seems to be adding your rule to PREROUTING rules (the last firewall line you posted), but I'm not quite sure you can add rules about "filter" table to rules about "nat". I am maybe wrong, but be cautious doing that
You dont really need anything else to allow unmatched trafic there,if you default rules (policy) is set to accept, this should work 
|
|
|
04-25-2005, 09:44 AM
|
#3
|
Member
Registered: Feb 2005
Location: Ottawa/Montréal
Distribution: Slackware + Darwin (MacOS X)
Posts: 468
Original Poster
Rep:
|
Thanks for the reply.
Firstly, without --match-multiport for some reason I get an error with --dport. I didn't think I needed it either but it seems that mixing matches (like -s and --dport) seems to need a --match. Anyway, it works that way, but thanks for the observation.
What's wrong with mixing nat and filter table rules since they apple to different chains that are called from each other?
|
|
|
04-26-2005, 10:25 AM
|
#4
|
LQ Guru
Registered: Sep 2001
Location: Montreal, Canada
Distribution: Slackware; Debian; Gentoo...
Posts: 2,163
Rep:
|
You only need multiport when you specify more than 1 port, I think.
About nat table and filter... Nat table isn't used at the same moment or to do the same things as filter, filter is mostly used about local connection and nat, to connection re-routed somewhere else, mixing both is a strange way to do so atmo.
But this is mostly standardisation/programmation concerns, it shouldn't cause any problem. If this work for you, you might want to keep it just like this, it doesnt matter much 
|
|
|
All times are GMT -5. The time now is 02:22 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|