Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Security
User Name
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.


  Search this Thread
Old 10-28-2007, 10:32 AM   #16
LQ 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 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 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
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
LQ 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:

# 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:

# Set the scripts to be executed after determination is made:

# Now we get the specs of the network you are currently in:
CURRENT_ROUTER_MAC=$(arping -c1 $(route -n | grep ^ | 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}')

# Now we check if they all match, and execute the appropriate script depending
# on whether or not they did:
     && [ $CURRENT_HOSTNAME = $HOSTNAME ]; then

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


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:38 PM.

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