LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 02-27-2014, 07:18 AM   #1
threehappypenguins
LQ Newbie
 
Registered: Feb 2014
Posts: 3

Rep: Reputation: Disabled
AFWall+ iptables help


I am attempting to block connection to a specific BSSID. My friend's son has been getting around the access restrictions I set for the family on my friend's behalf (I have Tomato running on his Linksys), and his son has access to the neighbour's wifi. I want to be able to block the connection to this wifi. I am experimenting with this at home by trying to block my phone from accessing my router. I tried this IP table first:

$IPTABLES -A INPUT -m mac --mac-source 00:00:00:00:00:00 -j DROP

(of course, the 00:00:00:00:00:00 represents the actual MAC address which I am not posting here; and I used all caps for the address)

I still had access to the internet.

I also tried:

$IPTABLES -A INPUT -m mac --mac-source 00:00:00:00:00:00 -j REJECT

Still had access. Though this is not ideal (because the public IP is dynamic and I have no access to the neighbour's router to add a dynamic dns address to implement this should I go this route), I then tried my public IP address:

$IPTABLES -I INPUT -s 11.222.33.44 -j DROP

I still had access to the internet through my router. So I tried this iptable for the fun of it:

$IPTABLES -I INPUT -s 11.222.33.44 -j REJECT

I could still access the internet. Is it even possible to do what I'm trying to do?

P.S. - My phone, as well as my friend's son's phone is rooted.

Last edited by threehappypenguins; 02-27-2014 at 09:54 AM.
 
Old 02-28-2014, 09:49 AM   #2
threehappypenguins
LQ Newbie
 
Registered: Feb 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
I figured things out. For one, after I added the iptable rule, I needed to REBOOT my phone for it to apply (which I wasn't doing). Secondly, I needed to use the LAN Mac Address (NOT the BSSID/Wireless MAC address) in order for the iptable rule to work.

Secondly, I downloaded AFWall+. It allowed me to set it as administrator to prevent uninstallation. The only thing missing is that the developer needs to password protect removing the app as administrator.

Then I downloaded Android Terminal Emulator. In order to find the LAN MAC address for the connection that I am looking to block, I typed this into the emulator:

arp -n

Then I used the MAC address that was given in the terminal and put that into this rule here to be place in "custom scripts" in the firewall:

$IPTABLES -A INPUT -m mac --mac-source 00:00:00:00:00:00 -j DROP
 
Old 03-01-2014, 04:34 AM   #3
brebs
Member
 
Registered: May 2013
Posts: 89

Rep: Reputation: Disabled
The *order* of iptables rules is absolutely crucial.

So we can't say whether your DROP/REJECT rule is useful, without seeing the output of "iptables-save", to see whether an earlier ACCEPT takes precedence
 
Old 03-01-2014, 05:57 AM   #4
threehappypenguins
LQ Newbie
 
Registered: Feb 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by brebs View Post
The *order* of iptables rules is absolutely crucial.

So we can't say whether your DROP/REJECT rule is useful, without seeing the output of "iptables-save", to see whether an earlier ACCEPT takes precedence
I'm really not sure what you mean. How would I see the output? You mean if I look at the firewall rules? Either way, it works. I'm blocked off the internet. But I later thought of something better. I was so concerned with my friend's son accessing the neighbour's wifi, that I neglected to think about the fact that I could use iptables to set time restrictions on his own phone. So I can set it so it would boot him off at 11:30pm every night whether he's at home (and trying to use the neighbour's wifi), on vacation, at a friend's house for a sleepover, travelling, etc.

Here is the code I used:

Code:
$IPTABLES -A INPUT -m time --timestart 03:30 --timestop 11:30 --weekdays Sun,Mon,Tue,Wed,Thu,Fri,Sat -j DROP
At first when I was testing it, it wasn't working (I even rebooted my phone). Then I decided to open Android Terminal Emulator and type:

Code:
date
The time was showing in GMT! Even though the time was set to my own timezone in the Android settings, in reality the iptables was using GMT (I guess all Androids use GMT 'internally' no matter the settings?).

So I had to add four hours to the time in my iptable rule to compensate (I'm Atlantic Time in Canada). Worked like a charm.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables can't initialize iptables table `filter': Bad file descriptor donalbane Linux - Networking 2 08-17-2011 08:36 AM
iptables error in android: iptables-save and iptables-restore not working preetb123 Linux - Mobile 5 04-11-2011 01:56 PM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 08:20 PM
Iptables - Couldn't load target `ACCPET':/lib/iptables/libipt_ACCPET.so: z00t Linux - Security 3 01-26-2004 02:24 AM
IPtables Log Analyzer from http://www.gege.org/iptables/ brainlego Linux - Software 0 08-11-2003 06:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration