ifswitch - network interface configuration switching tool v0.9.2 (60 Downloads)

With this tool you can switch your w/lan config very fast;
It was mainly written to offer very special functions like automatic mac-changing and adding static arp entries,
which isn't possible with normal tools and startup scripts. It is intended to be used on an "unfriendly" network or in pentests :)

The following settings can be made in the config file:
- interface ip (eth0_ip=... or eth0_ip=random or eth0_ip=random#pre.fix)
- broadcast (eth0_broadcast=...)
- netmask (eth0_netmask=...)
- default gateway (defaultgate=...)
- dns server(s), you can specify multiple lines (dns=ip)
- mac address; complete, prefix or random (eth0_mac=aa:bb:cc:dd:ee:ff or eth0_mac=random or eth0_mac=random#pr:ef:ix)
- static arp entries to prevent arp spoofing attacks, you can specify multiple lines (static_arp=ip#mac)
- wlan ssid & wep key (eth0_ssid=ssid#key)

Sample config files:
lan, wlan and dhcp

For every configuration, you have to put a file in your CONFDIR (which has to be specified in the header of ifswitch)
I did it this way, because it allows you to easily create configs for different w/lans which you can send to others using it.
You wouldn't like to share a huge config file with your private WEP key for your homelan, would you?

DO NO FORGET TO CREATE YOUR CONFDIR (/etc/ifswitch)!
Merged from llog and wlog (previously written for wlan and lan configuration switching).


Changelog:

12.12.2005 - Started coding, alpha ready
13.12.2005 - Fixed bug in addconfig()
           - added showconfig() to the menu
           - added [k]ill dhcpcd to the menu
           - rewritten randmac, now you can use a prefix for randmac -> randmac 00:00:86
           - added RANDOM / randip -> random ips possible, you can also use a prefix -> randip 192.168.0
           - changed parseconfig() and addconfig() to work with randmac/randip
15.12.2005 - added rotate command line switch, useful if you're pentesting ;)
18.12.2005 - confirmed that WLAN mode works fine :)
27.12.2005 - fixed typo with wlan
           - fixed severe error with using macs
03.01.2006 - created killdhcpcd()
           - CONFDIR will now be created if it does not exist and you try adding an entry
           - Released under the GPL-v2
23.01.2006 - removed exit() when iwconfig isn't found: maybe someone just wants to configure a LAN 
31.01.2006 - wrote an ebuild for Gentoo linux

TODO:

- exclude mode for RANDOM
- check if RANDOM ip/mac is already there
- use ip & netmask for calculation of random ip
- add WPA(2) support

Known bugs:

- When creating config files via hand you can get into trouble. Just use the menu dialog to create configs.


You should use the menu, especially for creating configs!

Just run ifswitch without any comand line switches:



ifswitch - network interface config switcher v0.9.2

[u]se existing config
[s]how configs
[a]dd network configuration
[d]elete an existing config
[t]est internet connectivity
[k]ill running dhcpcd
[r]estart pcmcia services
[e]nd
>


Some command line modes are also available:

# ./ifswitch --help
ifswitch - network interface config switcher v0.9.2
usage: ifswitch [Config-NR] [rotate] [time to wait between rotate]
[-show]
Command line mode is mostly only used for rotate-mode
Call ifswitch without arguments to use the menu

# ./ifswitch -show

[1]: "School, WLAN, static ARP, random MAC"
[2]: "Standart DHCP network"
[3]: "22C3 Cable LAN, DHCP, static ARP, random MAC"

# ./ifswitch 1

Setting mac de:ad:be:ef:ca:fe on interface eth0: OK
Using essid WLAN with key 12345 on interface eth0: OK
Setting ip 172.16.85.123 on interface eth0: OK
Setting netmask 255.255.0.0 on interface eth0: OK
Setting dns server 192.168.0.2: OK
Setting default gateway 172.16.1.200: OK
Adding static arp entry 192.168.0.2/00:11:22:33:44:55 : OK


# ./ifswitch 3 rotate 60

Setting random mac 00:21:12:32:cf:fa on interface eth0: OK
Using DHCP auto configuration: OK
Adding static arp entry 192.168.0.2/00:11:22:33:44:55 : OK

Setting random mac 00:18:31:4b:ca:01 on interface eth0: OK
Using DHCP auto configuration: OK
Adding static arp entry 192.168.0.2/00:11:22:33:44:55 : OK

... this will re-run the ifswitch configuration nr 3 every 60 seconds
This is useful if you want to stay anonymous on a LAN ;)



Written by Stefan Behte
Contact me, if you have any new ideas, bugs/bugfixes, recommondations or questions!
Please also contact me, if you just like the tool. :)

Stefan dot Behte at gmx dot net

Released under the GPL-v2