GNS3
http://forum.gns3.net/

Bridge with a Wireless NIC on Linux
http://forum.gns3.net/topic19.html
Page 1 of 1

Author:  grossmj [ Wed Oct 15, 2008 4:11 pm ]
Post subject:  Bridge with a Wireless NIC on Linux

HOWTO originally posted by rogan2929 on hacki's forum and adapted for GNS3.

So in short, your Linux box will need to be configured as a fully functional router with NAT. It will be forwarding packets between your wireless card and your loopback interface.

One more thing to note though, this guide will only work if you run GNS3 as root. Otherwise the program won’t be able to enumerate installed network interfaces.

To do this, you need to follow the steps outlined below.

For the purposes of this tutorial the wireless NIC will be called wlan0.

STEP 1

Install and configure the tap0 interface. An excellent guide is posted at http://www.blindhog.net/cisco-using-dyn ... et-router/. Look for the flash video called, “How to connect dynamips to a Linux tap interface”. This video assumes you’re running some version of Ubuntu / Debian. Other distributions should be able to find a similar package file, or at the very least get the source tarball.

If you’re feeling creative, add the line “tun” to your /etc/modules file and then add the tap0 interface to your /etc/network/interfaces file so that it loads on boot, it will save time. Otherwise you’ll have to manually configure the interface after each restart!

Here’s the relevant snippet from /etc/network/interfaces file:

Code:
auto tap0
iface tap0 inet manual
up ifconfig $IFACE 172.16.0.1 netmask 255.255.0.0 up
down ifconfig $IFACE down
tunctl_user root


STEP 2

The next step is to configure IPTables so that it automatically transfers packets between wlan0 and tap0. Here is a simple script that will do this. Keep in mind, it doesn’t have any real security built into it; it’s just used for playing with GNS3.

Code:
# Simple script to enable IP packet forwarding and NAT
#
# wlan0 is Internet connected interface

# Enable IP Forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

# Clean up iptables
iptables -F
iptables -t nat -F
iptables -X

# Enable IP MASQUERADING/NAT
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

# Set firewall policies
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

# Allow all connections not from wlan0
iptables -A INPUT -i ! wlan0 -j ACCEPT

# Allow all ICMP connections
iptables -A INPUT -p ICMP -j ACCEPT

# Allow all already established connections
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT


And that’s it. Very simple and straightforward. You still might need to configure your virtual router to send packets out the tap0 interface, however. If you’re not sure how to do that, pick up a book and start studying!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/