Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts

Saturday, 19 October 2013

Bash script wrapper for Easy Firewall Generator IPTables

I wanted a gateway firewall, to share internet access from one interface to another.  Iptables is excellent for this, but setting it up manually is a pain.

Easy Firewall Generator provides a excellent gateway iptables script but in my environment the interface names could change and manually editing the script is no good.

This script basically a 'wrapper script' for the Easy Firewall Generator script, with a few mods.

The usage is: 
./ics.sh -i [Internet Interface] -e [Sharing Interface] -a [Sharing IP Address]
 
For example, if eth0 had internet access and I wanted to share the internet connection to hostapd wlan0 (10.0.0.1) then the command to enable sharing would be:

./ics.sh -i eth0 -e wlan0 -a 10.0.0.1


You will need to generate a iptables 'firewall script' using the Easy Firewall Generator site.
  • On the website just select arbitrary values for the interfaces and ip addresses.
  • On the website, in section "Select Type of Internet Address ", select "Dynamic Internet IP Address"
  • Click generate, save the code, comment out the "Internet Interface" and the "Local Interface Information" sections in the saved 'firewall script'.
  • In the 'firewall script' remove the first line "#!/bin/sh"
  • Then add the raw 'wrapper script' below to the top of your firewall script.
  • Save and chmod +x the file before trying it out.


Those instruction suck.
Find the script here or below:




WindyCityTech Blogger
WindyWindyCityTech Wordpress

UPDATE: Modern Bash Wifi Connection Script for Linux; goodbye network manager

An update to a previous post.  This script has some more command line features, including a random_config_mode.

The random config mode can be used to check several AP's in the area for internet access.  In internet cannot be found, the script will randomly try another connection until internet can be found again.  The timer to check for internet access is randomly set between 60 to 90 seconds for an extra touch.
A preferred AP can be initially chosen in the random mode, so if it does fail, another connection will become selected.  In no way is this script perfect, results may vary depending what distro you are using.

Completely run from the command line.  Great for Raspberry Pi.

View it here: http://pastebin.com/vcVC9iL9

or below.



WindyCityTech Blogger
WindyWindyCityTech Wordpress

Saturday, 31 December 2011

Backup Home folder on Ubuntu onto a USB drive for upgrades on Linux

It is that simple, before a upgrade:

rsync -a -u  /home/ /media/you_usb_drive/your_backup_folder

Copies all hidden dotfiles, preserves permissions.


WindyCityTech Blogger
WindyWindyCityTech Wordpress

Sunday, 12 June 2011

How to remove exif tags using Ubuntu

Exif data provides a interesting insight to how and possibly where a photo was taken, however sometimes you may want to remove the data embedded in your jpg files.

I will be using two lightweight console programs:

exif - Displays the exif data using a console

mogrify - Amongst other things, strips exif data (part of imagemagick package)

Shown below is a screen dump of exif in action.  The command to show machine readable exif information is 'exif -m picture.jpg'


Now use mogrify to strip the tags 'mogrify -strip *.jpg'
Note:  morgrify will overwrite/append all files, which is what we want most of the time.

A retest with exif, shows the tags are gone!



WindyCityTech Blogger
windywindycitytech wordpress

Saturday, 23 April 2011

sudo !! tip, bash-fu


Never knew this one before.  Makes it easier when you forget to sudo something.