LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-28-2007, 10:32 AM   #16
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371

If the OR operator (||) works the same in a conditional statement as it does on the command-line, then the part after the || would only be looked at if the part before it fails (or in this case, evaluates to false). In other words, the statement would evaluate to true if either part succeeds. Are you trying to get it to skip the WAN IP check if you have a dynamic IP? Perhaps we would be better-off simply forgetting about the WAN IP check and instead have your home router's DHCP server assign a non-typical "static" IP to your laptop all the time (something like 192.168.192.235 or whatever). Then we just check to see if we have that IP. Considering neither approach is secure, we aren't giving anything up. We actually gain not having to depend on the whatismyip.org server. It's just a thought.

Last edited by win32sux; 10-28-2007 at 10:41 AM.
 
Old 10-28-2007, 10:52 AM   #17
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Original Poster
Rep: Reputation: 66
I agree. I like when things work in the most general case. And you can't assume all networks are connected to the internet.
 
Old 10-28-2007, 11:04 AM   #18
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Well, it could be done like this then:
Code:
#!/bin/sh

# This script will execute a certain script if it detects that your
# router's MAC address, your host IP address, and your hostname are what
# they would be when at home. It'll also execute a certain script if
# it finds that they aren't.

# Set the specs for your home network here:
ROUTER_MAC="xx:xx:xx:xx:xx:xx"
HOST_IP="xxx.xxx.xxx.xxx"
HOST_IFACE="eth0"
HOSTNAME="xxxxxxxxxxxxxxx"

# Set the scripts to be executed after determination is made:
AT_HOME_SCRIPT="/home/meson/firewall-samba.txt"
NOT_AT_HOME_SCRIPT="/home/meson/firewall-stealth.txt"

# Now we get the specs of the network you are currently in:
CURRENT_ROUTER_MAC=$(arping -c1 $(route -n | grep ^0.0.0.0 | awk '{print $2}') \
                   2> /dev/null | grep "Unicast reply from" | awk '{print $5}' \
                   | cut -c 2-18)
CURRENT_HOST_IP=$(ifconfig | grep -A 1 $HOST_IFACE | tail -n 1 | \
                awk '{print $2}' | awk -F: '{print $2}')
CURRENT_HOSTNAME=$(hostname)

# Now we check if they all match, and execute the appropriate script depending
# on whether or not they did:
if [ $CURRENT_ROUTER_MAC = $ROUTER_MAC ] && [ $CURRENT_HOST_IP = $HOST_IP ] \
     && [ $CURRENT_HOSTNAME = $HOSTNAME ]; then
  sh $AT_HOME_SCRIPT
else
  sh $NOT_AT_HOME_SCRIPT
fi

Last edited by win32sux; 10-28-2007 at 11:09 AM.
 
  


Reply

Tags
firestarter, firewall, iptables


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Mapping IP addresses to MAC addresses basilio Linux - Networking 17 09-12-2007 01:48 AM
Lan subnet and mac addresses firewall Ungluun Linux - Networking 1 12-20-2006 10:18 AM
Firewall considerations - 2 Dual boot PCs rickh Fedora 3 04-26-2005 10:06 PM
Mac Addresses nixdisciple Linux - Security 6 07-01-2002 10:55 PM
Finding mac addresses Chijtska Linux - Security 5 02-27-2002 04:34 AM


All times are GMT -5. The time now is 11:26 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration