Bridging wireless AP - bridge-utils

Hi there,
Situation:
1. Free AP next to my home, signal weak, not everywhere accessable.
2. Laptop with wireless interface + Wireless USB-Dongle (good antenna, extended range) + Siemens SE361 WLAN Router
3. I connect with my USB-Dongle to the Free AP, I have set a wireless network with SE361 and connect to it with the internal wireless card of my laptop
This so far worked, but now I want to have internet access at the SE361-Network and I think I need to bridge both networks. I tried with bridge-utils but brctl addbr <mybridge> <mywlanif> gives me an error (can't add wlan0 to bridge br0: Operation not supported) so I think I can only bridge ethernet networks with it (adding eth0 instead of wlan0 works).
On google I only found stuff about a hardware bridge or how to bridge ethernet networks.
Now I need some help how I can get this working, cau you help me please?
Is bridging even the right thing to do in this case or can I forward the internetconection somehow else?

Here is a simple config example
Root                                                                           Non-Root
R(config)#dot11 ssid test                             n-R(config)#dot11 ssid test
                #authentication open                    n-R(config)#authentication open
               #infrastructure-ssid                       n-R(config)#infrastructure-ssid
               #exit                                                                  #exit
R(config)#int d0                                          n-R(config)#int d0
               # ssid test                                                  #ssid test
                #statio-role root bridge wireless-client          #station-role non-root bridge wireless-client
                #no shut                                                   #no shut
For BVI interfaces you can assign either static or dynamic IP address
But it is highly recommended to have static ip for better management.

Similar Messages

  • PB Surfs Web Wirelessly, But Admin Util Can't "see" Airport Express - Huh?

    Hi All --
    I have a friend (no really a friend, not me, I swear ;-)) with the set-up described below and a seemingly impossible problem. He's asked for my help, and so I'm asking for yours, because frankly the situation just has me stumped. Here goes:
    Set-Up & Other Relevant Facts
    • DSL connection comes out of the phone jack and goes to a Westell model 6100 modem.
    • From there, a short Ethernet cable goes to a Linksys 5-Port Workgroup Switch.
    • Two Ethernet cables exit the Linksys Switch: one goes to a PC, and one goes to an Airport Express (AX).
    • From the AX, a USB cable goes to a printer (a Brother 1440 laser printer).
    • The AX is only about 10 feet from his PowerBook G4 15-inch and he gets a full (four-bar) signal on Airport menulet at the top of the screen.
    • When he first set-up his system, the G4 and the Airport did set up the Brother printer (using the Airport Setup Assistant), and the Brother is listed as a printer on the G4's printer window or such.
    • Both the G4 and the PC access the web fine via this setup (the G4 wirelessly). In System Preferences > Network, the Airport Network is listed, and it says "Airport is connected to the network Apple Network 6c6c1. You are connected to the Internet via Airport."
    Problems
    • When the Airport Admin Utility is opened, no Airport Express appears at all, even when "rescan" is repeatedly clicked.
    How can this be? How can the PowerBook be connecting wirelessly to the Web through the Airport Express, but the Airport Express no be "seen" by the Airport Admin utility?
    • In addition, although web surfing is possible for both PowerBook and PC, neither computer is able to successfully print to the Brother 1440. When he tried printing from the PC, he got the following error messages:
    [Status for LPT1]
    Result=(02)The printer on this port is not responding.
    Status Line=BUSY:H,ACK:H,PE:H,SLCT:H,FALT:H,SLIN:L,HBSY:H,INIT:H,STB:H
    Later, it seemed that printing from either computer would start and then stall, flashing a variety of different signals about spooling or "printer busy" and the like, all of which appeared to indicate things just weren't working right..
    Anyway, the initial questions we're dealing with are the ones in bold above. The printer issues are probably are related and they can be addressed secondarily.
    Any and all help with this will be greatly appreciated. Thanks everyone.
    -- JDee
    Please excuse this duplicate post, but I posted this this morning in the AIrport Express forum at about 8 a.m. and have thus far received no replies at all. In fact, it's only been viewed a total of nine times -- and half of those are me. Very sad, and my friend is growing fairly desperate and is now convinced that only a complete reset and fresh start will fix his problem......

    Hi JDee,
    Well, it's the old 'friend of mine' gag, eh. Seriously though, it seems there have been numerous post over in the Aiport forums regarding this issue. I guess the first thing your friend can try is following these instructions to reset the AE. One of the other things discussed was the firmware version for AE. Some users have reported that version 6.1.1 works better than 6.2. One user reported being able to use the other button in AE admin utility, then entering the assigned IP address and password to gain access. One user resolved his issue by enabling the setting Distrubute IP addresses in the AE. It should be noted he also reset up his network at that point as well. Now as far as the printer goes, below are some instructions from iFelix for the Windows side which may be of some help.
    Printing from Windows to AE
    Problem finding Printer Driver on Windows
    For the Mac side apparently there are issues with that model printer. Here's a link of compatible printers that iFelix put together. You'll see the notation next to the Brother 1440. Hope that helps a little. Sorry I couldn't be of more assistance.
    Jrsy

  • How can I add a client wireless usig Airport Utility 6.0?

    In menu airport of firmware 6.0 there is not window "Add a wireless client". I'm using Mac Os lion with Airport Utility6.0, how can I add a client wireless with this firmware)?

    If you have a dual band AirPort Extreme, you can add another to "extend" both bands of your network to provide more  wireless coverage.
    The "best" way to do this is to connect the "remote" access point back to your main AirPort Extreme using an Ethernet connection. This preserves bandwidth on the network better than any other method...and...you can locate the "remote" Extreme exactly in the area where more coverage is needed. Instructions for thhis are here:
    http://support.apple.com/kb/HT4260
    You might be able to connect using wireless only, but this is always "Iffy".
    In general, the Extreme would need to be located approximately half the distance from your main router to the general area that needs more coverage. But, walls, ceilings and other obstructions usually come into play, requiring some experimentation. Instructions are here:
    http://support.apple.com/kb/HT4259
    If you elect to try wireless, you really won't know if things will work until you try. Recommend that you have a "Plan B" if wireless does not work for your purpose.

  • Finding the wireless network manager utility

    how do i access and open the wireless network manager on my imac?

    On my 10.6.8 iMac there's an inverted triangle at the top right section of the screen.  Click on it, and a drop down menu will appear.  Click on network preferences> a window will appear>click "Turn Airport on" and start managing. Hopefully,your Mid 2007 is similar. NOTE: These instructions are for managing the internal wi fi system within your iMac computer
    Wuz

  • Deskjet 3512 connected to wireless network but utility says 'Unable to find printer'

    1. Product Name and Number
         • HP Deskjet 3512
     2. Operating System installed (if applicable)
         • Windows 7 64-bit
     3. Error message (if any)
         Unable to find printer.
        Facts:
    - Printer is connected to network. Panel LED is unblinking blue and the status indicates the correct SSID for my network. Also the router config page indicates that the printer is connected with a correct IP (192.168.1.XX).
    - Wireless Network Test Results diagnostics of the printer states that all PASSED, except that the Internet says 'Not connected'.
    - Tried to ping the IP that the printer panel says, but cmd says: Destination Host Unreachable. Tried arp -a after that but it does not show the IP & MAC address of the printer.
    - Turned off: Windows firewall, router firewall (Telus Actiontec V1000H) and disabled MAC Address Control and uninstalled Avast AV and reboot.
    - Cannot access printer Embedded Web Server.
    - Tried the HP Print and Scan Doctor and it didnt find the printer. And when it did find it, it was by using the USB cable. After selecting the fixes, it came to 'Unable to Find Printer again'.
     4. Any changes made to your system before the issue occurred
         • No changes. Bought the printer and I'm having this issue.
    PLEASE HELP!

    To start out sounds like this is a driver issue. I want to start with being sure that the removal of the software and reinstallation happened in the best possible fashion. I want you to follow my steps so I can be sure that we are both starting on the same page.
    First if you use a USB cord, make sure to remove it (this is important). Do not plug it back in until the software directs you to. Then go through the Devices and Printers, Programs and Features and Device Manager folders and insure that all copies, files, and programs related to the printer are removed. Then as directed, restart the computer.
    In the START menu type "%temp%" and press ENTER. Here I want you to press Ctrl+A and hit DELETE. Some of the files will not allow you to delete them, skip those files and delete the majority that allows it.
    find and install the FULL FEATURE SOFTWARE if it is available :
    http://h10025.www1.hp.com/ewfrf/wc/softwareCategory?cc=us&lc=en&dlc=en&product=5241114
    Install that and let me know the result!
    Have a great day!
    -Spencer

  • Bridge between wired and wireless

    This is what I am hoping to accomplish
    router *****wireless connection 802.11******wlan0 - laptop - eth0 --------Wired ethernet---------------- another host(s)
    routers IP is 192.168.1.1
    The "other host(s)" need to be able to pull information via dhcp from the router.
    What I've tried so far
    I've installed bridge-utils and enabled ip forwarding in /proc
    brctl addbr br0
    brctl addif br0 wlan0
    brctl addif br0 eth0
    This is where I get lost. I think I need to manually configure wlan0 and eth0. In Ubuntu I think I remember setting br0 to bridge_ports in /etc/network.d/interfaces but I am not sure how to do this in Arch.
    Any suggestions?
    Thanks
    band-aid
    Ok I think I have been going about this all wrong, is it possible to do what I need to do using iptables masquerading?
    Last edited by band-aid (2008-07-21 07:20:33)

    You can use bridging OR ip masquerading - you don't need both. If you use bridging, wlan0 and eth0 join the bridge, which then gets its own virtual interface br0. This is the interface that gets an IP address, so that the laptop can continue to function normally. In this scenario, everything is on  single subnet, and no ip forwarding or routing manipulation is required.
    If you use IP masquerading, you're basically setting up NAT (Network Address Translation). The router and wlan0 are on one subnet, eth0 and the other hosts(s) are on another, and the laptop functions as the router between the two - as well as doing its normal laptop-y things, of course.
    There are probably various pros and cons either way - one that occurs to me now is that the IP masquerade option will probably leave you with a double-NAT setup, because your existing router is most likely doing NAT already. This may or may not be a problem for you - depends really on the kind of network apps you will be running. Personally, I prefer bridging in this kind of situation, just because I find it simpler.

  • Bridging wifi and ethernet; bring interface up with netcfg

    using bridge-utils I was able to establish a bridge between my ethernet port and my wireless interface.  My wireless interface is the source of the Internet connection on the computer, and the ethernet port is going to send that Internet connection to a nearby computer.  My questions are:
    Is it possible to bring this bridge up via netcfg, so that the wireless interface connects to the desired router?
    If not, how can I use a bridge to bring up a wireless Internet connection using other applications, so that I can write a script to trigger it when I need it?

    So I had this working for a while, and lately I've been using it to bring Internet access to my Xbox 360, which is even more distant from the main router than the desktop I had been using.  It is also a much better use of the bridging in economical terms, since the wireless component for the Xbox is $100 (price gouging jerks...).
    Then yesterday I tried it and the Xbox wouldn't connect.  After fiddling around, I found two things out:
    1. Since the last time I connected the Xbox to the net, I had ran yaourt -Syu, which updated iptables from 1.4.5-x to 1.4.6-1
    2. The specific issue is that, despite the following line in my "ethernet-xover" network profile...
    POST_UP="iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE ; echo 1 > /proc/sys/net/ipv4/ip_forward ; /etc/rc.d/iptables save ; /etc/rc.d/iptables restart"
    ... /proc/sys/net/ipv4/ip_forward isn't getting set to 1.  Once I manually set it to 1, the connection works.
    So I'd like to take this opportunity to peer review this profile, to a) see why echoing is failing, and b) find out if it is really necessary to restart iptables as shown here.

  • [Solved] How to create a ntework bridge device?

    Hi!
    I'm trying to create a network bridge device for using it with KVM.
    Therefore I installed netctl and bridge-utils.
    I have two network interfaces in my computer. net0 and net1.
    net0 is connected to a network switch and gets its address via DHCP.
    net1 is disconnected.
    My aim was to create a new device, br0, that uses net0 to get an IP address from the DHCP server of my network.
    So I created the following configuration:
    [mine@intelmine ~]$ cat /etc/netctl/bridgekvm
    Description="Bridge for KVM"
    Interface=br0
    Connection=bridge
    BindsToInterfaces=(net0)
    IP=no
    ## sets forward delay time
    FwdDelay=0
    ## sets max age of hello message
    #MaxAge=10
    When I start this configuration with the command
    systemctl start netctl@bridgekvm
    The br0 interface appears:
    [root@intelmine ~]# ifconfig
    br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet6 fe80::225:22ff:fe67:d6c0 prefixlen 64 scopeid 0x20<link>
    ether 00:25:22:11:d6:c0 txqueuelen 0 (Ethernet)
    RX packets 2 bytes 382 (382.0 B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 5 bytes 478 (478.0 B)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
    lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
    inet 127.0.0.1 netmask 255.0.0.0
    inet6 ::1 prefixlen 128 scopeid 0x10<host>
    loop txqueuelen 0 (Local Loopback)
    RX packets 757 bytes 53267 (52.0 KiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 757 bytes 53267 (52.0 KiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
    net0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST> mtu 1500
    inet 192.168.5.10 netmask 255.255.255.0 broadcast 192.168.5.255
    ether 00:25:22:11:d6:c0 txqueuelen 1000 (Ethernet)
    RX packets 560686 bytes 773497800 (737.6 MiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 321142 bytes 49144250 (46.8 MiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
    net1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
    ether 00:02:12:3d:23:a4 txqueuelen 1000 (Ethernet)
    RX packets 0 bytes 0 (0.0 B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 0 bytes 0 (0.0 B)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
    tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
    inet 10.38.0.18 netmask 255.255.255.255 destination 10.38.0.17
    unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 100 (UNSPEC)
    RX packets 548425 bytes 720892580 (687.4 MiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 541569 bytes 362557409 (345.7 MiB)
    TX errors 0 dropped 227425 overruns 0 carrier 0 collisions 0
    The strange thing is, that the br0 device gets the same MAC address as the net0 device.
    Right after activating the netctl profile, I cannot ping any host on the network anymore.
    When stopping the netctl profile both devices, net0 and br0 disappear:
    [root@intelmine ~]# systemctl stop netctl@bridgekvm
    [root@intelmine ~]# ifconfig
    lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
    inet 127.0.0.1 netmask 255.0.0.0
    inet6 ::1 prefixlen 128 scopeid 0x10<host>
    loop txqueuelen 0 (Local Loopback)
    RX packets 2597 bytes 147170 (143.7 KiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 2597 bytes 147170 (143.7 KiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
    net1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
    ether 00:02:44:3d:23:a4 txqueuelen 1000 (Ethernet)
    RX packets 0 bytes 0 (0.0 B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 0 bytes 0 (0.0 B)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
    tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
    inet 10.38.0.18 netmask 255.255.255.255 destination 10.38.0.17
    unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 100 (UNSPEC)
    RX packets 548425 bytes 720892580 (687.4 MiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 5308955 bytes 7506979179 (6.9 GiB)
    TX errors 0 dropped 4987835 overruns 0 carrier 0 collisions 0
    What is going on here? How can I simply create a bridge device for a KVM host?
    Thanks,
    newpipe
    Last edited by newpipe (2013-07-01 08:07:56)

    Thanks for the clarification, teekay!
    I was just confused because of the behaviour of virtualbox. There you can also set bridged network to the guests, but you don't need to change anything on the host config.
    Now I understand that I just need to disable the interface in the Network Manager, create the bridge device with the wished IP config for the host and tell the guest to use that bridge interface. The guest then gets a new interface with a new MAC and IP config but connected to the bridge interface.
    Now everything works for me. Thanks a lot for your help!
    newpipe

  • [SOLVED] KVM and Bridged Networking

    I've got KVM working and a Windows 2008 server installed on a image now, but it's only getting a NAT ip address. I need to get this server onto my main network, on Windows I'd use Virtual Box and Bridged Networking, but I thought I'd give KVM a try out.
    I've followed the setup at https://wiki.archlinux.org/index.php/KV … Networking
    Using Netcfg
    Bridged networking is used when you want your VM to be on the same network as your host machine. This will allow it to get a static or DHCP IP address on your network, and then you can access it using that IP address from anywhere on your LAN. The preferred method for setting up bridged networking for KVM is to use the netcfg package. You will also need to install bridge-utils.
    Netcfg#Configuring_a_bridge_for_use_with_virtual_machines_.28VMs.29
    And this page https://wiki.archlinux.org/index.php/Ne … _.28VMs.29
    I've got a bridge working I believe (all my stuff is DHCP by the way)
    Output of ifconfig
    br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 metric 1
    inet 192.168.1.52 netmask 255.255.255.0 broadcast 192.168.1.255
    inet6 fe80::21d:7dff:fea9:bb2f prefixlen 64 scopeid 0x20<link>
    ether 00:1d:7d:a9:bb:2f txqueuelen 0 (Ethernet)
    RX packets 2966 bytes 520670 (508.4 KiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 2351 bytes 1874150 (1.7 MiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
    eth0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST> mtu 1500 metric 1
    ether 00:1d:7d:a9:bb:2f txqueuelen 1000 (Ethernet)
    RX packets 2977 bytes 570261 (556.8 KiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 2364 bytes 1875202 (1.7 MiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
    device interrupt 45 base 0xc000
    lo: flags=73<UP,LOOPBACK,RUNNING> mtu 16436 metric 1
    inet 127.0.0.1 netmask 255.0.0.0
    inet6 ::1 prefixlen 128 scopeid 0x10<host>
    loop txqueuelen 0 (Local Loopback)
    RX packets 72 bytes 7056 (6.8 KiB)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 72 bytes 7056 (6.8 KiB)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
    I've got "bridge" added to my rc.conf as a MODULE which is loaded. (I saw reference to this somewhere else on the forum that this might be needed)
    I'm starting my VM with the following command
    qemu-kvm -vnc 192.168.1.52:0 -hda Nekomi -m 2048 -smp 2 -net nic
    Yet I still can't get an IP outside of the 10.0.0.0 range on the VM.
    The VNC line above is because the HOST has not VGA output at all, completely headless.
    I'm trying to get this working and trying to learn at the same time. KVM is new to me, as is bridged networking on linux.
    Any ideas? Thanks
    Last edited by Naijeru (2012-09-18 16:28:20)

    Sorry for the delay, bit a PC rebuild occurred :-(
    Anyway, I managed to get this working with steps #1-#7 from the linked section. Thanks for that. I did have a few minor issues in getting a DHCP on the host machine itself, turns out I'd missed a single ) from the daemons section of rc.conf. A human error, but difficult to fix as the machine was rendered off the network and without a VGA card... fun!
    I diverge, I have this script to bring up a bridge when the qemu-kvm starts
    #!/bin/sh
    echo "Executing /etc/qemu-ifup"
    echo "Bringing up $1 for bridged mode..."
    sudo /sbin/ifconfig $1 0.0.0.0 promisc up
    echo "Adding $1 to br0..."
    sudo /usr/sbin/brctl addif br0 $1
    sleep 2
    But when the kvm shutdowns it complains it can't find qemu-ifdown script. So I'm thinking of making one but just want to check it over first.
    #!/bin/sh
    echo "Executing /etc/qemu-ifdown"
    echo "Removing $1 from br0..."
    sudo /usr/sbin/brctl delif br0 $1
    echo "Taking down $1 from bridged mode..."
    sudo /sbin/ifconfig $1 0.0.0.0 promisc down
    sleep 2
    I've reversed the logic here, is the above the correct way to bring down the guest interface?

  • [solved]virtualbox bridge-adapter error

    I wanna use virtualbox bridge-adapter, virtualbox works fine, and I already installed bridge-utils.
    but I cannot found uml_utilities by pacman or yaourt
    help, thanks
    ps: I use static ip by route
    Last edited by dxcqcv (2014-06-27 02:12:26)

    I got it, I forgetten to modprobe vboxnetflt, vboxnetadp and vboxpci
    no need to use uml_utilities
    thx~

  • [script] create_ap: Create a NATed or Bridged WiFi Access Point

    This script use hostapd + dnsmasq + iptables to create a NATed Access Point OR hostapd + brctl + dhclient to create a bridged Access Point.
    The default behavior is a NATed Access Point.
    updated script will be here: https://github.com/oblique/create_ap and http://git.2f30.org/create_ap/
    Examples
    No passphrase (open network):
    ./create_ap wlan0 eth0 MyAccessPoint
    OR
    echo -e "MyAccessPoint" | ./create_ap wlan0 eth0
    WPA + WPA2 passphrase:
    ./create_ap wlan0 eth0 MyAccessPoint MyPassPhrase
    OR
    echo -e "MyAccessPoint\nMyPassPhrase" | ./create_ap wlan0 eth0
    AP without Internet sharing:
    ./create_ap -n wlan0 MyAccessPoint MyPassPhrase
    Bridged Internet sharing:
    ./create_ap -m bridge wlan0 eth0 MyAccessPoint MyPassPhrase
    Internet sharing from the same WiFi interface:
    ./create_ap wlan0 wlan0 MyAccessPoint MyPassPhrase
    Usage
    Usage: create_ap [options] <wifi-interface> [<interface-with-internet>] [<access-point-name> [<passphrase>]]
    Options:
    -h, --help Show this help
    -c <channel> Channel number (default: 1)
    -w <WPA version> Use 1 for WPA, use 2 for WPA2, use 1+2 for both (default: 1+2)
    -n Disable Internet sharing (if you use this, don't pass
    the <interface-with-internet> argument)
    -m <method> Method for Internet sharing.
    Use: 'nat' for NAT (default)
    'bridge' for bridging
    'none' for no Internet sharing (equivalent to -n)
    --hidden Make the Access Point hidden (do not broadcast the SSID)
    --ieee80211n Enable IEEE 802.11n (HT)
    --ht_capab <HT> HT capabilities (default: [HT40+])
    --driver Choose your WiFi adapter driver (default: nl80211)
    --no-virt Do not create virtual interface
    Non-Bridging Options:
    -g <gateway> IPv4 Gateway for the Access Point (default: 192.168.12.1)
    -d DNS server will take into account /etc/hosts
    Useful informations:
    * If you're not using the --no-virt option, then you can create an AP with the same
    interface you are getting your Internet connection.
    * You can pass your SSID and password through pipe or through arguments (see examples).
    Examples:
    create_ap wlan0 eth0 MyAccessPoint MyPassPhrase
    echo -e 'MyAccessPoint\nMyPassPhrase' | create_ap wlan0 eth0
    create_ap wlan0 eth0 MyAccessPoint
    echo 'MyAccessPoint' | create_ap wlan0 eth0
    create_ap wlan0 wlan0 MyAccessPoint MyPassPhrase
    create_ap -n wlan0 MyAccessPoint MyPassPhrase
    create_ap -m bridge wlan0 eth0 MyAccessPoint MyPassPhrase
    create_ap --driver rtl871xdrv wlan0 eth0 MyAccessPoint MyPassPhrase
    Code
    #!/bin/bash
    # general dependencies:
    # bash (to run this script)
    # util-linux (for getopt)
    # hostapd
    # iproute2
    # iw
    # iwconfig (you only need this if 'iw' can not recognize your adapter)
    # haveged (optional)
    # dependencies for 'nat' or 'none' Internet sharing method
    # dnsmasq
    # iptables
    # dependencies for 'bridge' Internet sharing method
    # bridge-utils
    usage() {
    echo "Usage: $(basename $0) [options] <wifi-interface> [<interface-with-internet>] [<access-point-name> [<passphrase>]]"
    echo
    echo "Options:"
    echo " -h, --help Show this help"
    echo " -c <channel> Channel number (default: 1)"
    echo " -w <WPA version> Use 1 for WPA, use 2 for WPA2, use 1+2 for both (default: 1+2)"
    echo " -n Disable Internet sharing (if you use this, don't pass"
    echo " the <interface-with-internet> argument)"
    echo " -m <method> Method for Internet sharing."
    echo " Use: 'nat' for NAT (default)"
    echo " 'bridge' for bridging"
    echo " 'none' for no Internet sharing (equivalent to -n)"
    echo " --hidden Make the Access Point hidden (do not broadcast the SSID)"
    echo " --ieee80211n Enable IEEE 802.11n (HT)"
    echo " --ht_capab <HT> HT capabilities (default: [HT40+])"
    echo " --driver Choose your WiFi adapter driver (default: nl80211)"
    echo " --no-virt Do not create virtual interface"
    echo
    echo "Non-Bridging Options:"
    echo " -g <gateway> IPv4 Gateway for the Access Point (default: 192.168.12.1)"
    echo " -d DNS server will take into account /etc/hosts"
    echo
    echo "Useful informations:"
    echo " * If you're not using the --no-virt option, then you can create an AP with the same"
    echo " interface you are getting your Internet connection."
    echo " * You can pass your SSID and password through pipe or through arguments (see examples)."
    echo
    echo "Examples:"
    echo " $(basename $0) wlan0 eth0 MyAccessPoint MyPassPhrase"
    echo " echo -e 'MyAccessPoint\nMyPassPhrase' | $(basename $0) wlan0 eth0"
    echo " $(basename $0) wlan0 eth0 MyAccessPoint"
    echo " echo 'MyAccessPoint' | $(basename $0) wlan0 eth0"
    echo " $(basename $0) wlan0 wlan0 MyAccessPoint MyPassPhrase"
    echo " $(basename $0) -n wlan0 MyAccessPoint MyPassPhrase"
    echo " $(basename $0) -m bridge wlan0 eth0 MyAccessPoint MyPassPhrase"
    echo " $(basename $0) --driver rtl871xdrv wlan0 eth0 MyAccessPoint MyPassPhrase"
    # it takes 2 arguments
    # returns:
    # 0 if v1 (1st argument) and v2 (2nd argument) are the same
    # 1 if v1 is less than v2
    # 2 if v1 is greater than v2
    version_cmp() {
    [[ ! $1 =~ ^[0-9]+(\.[0-9]+)*$ ]] && die "Wrong version format!"
    [[ ! $2 =~ ^[0-9]+(\.[0-9]+)*$ ]] && die "Wrong version format!"
    V1=( $(echo $1 | tr '.' ' ') )
    V2=( $(echo $2 | tr '.' ' ') )
    VN=${#V1[@]}
    [[ $VN -lt ${#V2[@]} ]] && VN=${#V2[@]}
    for ((x = 0; x < $VN; x++)); do
    [[ ${V1[x]} -lt ${V2[x]} ]] && return 1
    [[ ${V1[x]} -gt ${V2[x]} ]] && return 2
    done
    return 0
    USE_IWCONFIG=0
    is_wifi_interface() {
    which iw > /dev/null 2>&1 && iw dev $1 info > /dev/null 2>&1 && return 0
    if which iwconfig > /dev/null 2>&1 && iwconfig $1 > /dev/null 2>&1; then
    USE_IWCONFIG=1
    return 0
    fi
    return 1
    get_phy_device() {
    for x in /sys/class/ieee80211/*; do
    [[ ! -d "$x" ]] && continue
    if [[ "${x##*/}" = "$1" ]]; then
    echo $1
    return 0
    elif [[ -e "$x/device/net/$1" ]]; then
    echo ${x##*/}
    return 0
    elif [[ -e "$x/device/net:$1" ]]; then
    echo ${x##*/}
    return 0
    fi
    done
    echo "Failed to get phy interface" >&2
    return 1
    get_adapter_info() {
    PHY=$(get_phy_device "$1")
    [[ $? -ne 0 ]] && return 1
    iw phy $PHY info
    can_have_sta_and_ap() {
    # iwconfig does not provide this information, assume false
    [[ $USE_IWCONFIG -eq 1 ]] && return 1
    get_adapter_info "$1" | grep -E '{.* managed.* AP.*}' > /dev/null 2>&1 && return 0
    get_adapter_info "$1" | grep -E '{.* AP.* managed.*}' > /dev/null 2>&1 && return 0
    return 1
    can_have_ap() {
    # iwconfig does not provide this information, assume true
    [[ $USE_IWCONFIG -eq 1 ]] && return 0
    get_adapter_info "$1" | grep -E '\* AP$' > /dev/null 2>&1 && return 0
    return 1
    can_transmit_to_channel() {
    IFACE=$1
    CHANNEL=$2
    if [[ $USE_IWCONFIG -eq 0 ]]; then
    CHANNEL_INFO=$(get_adapter_info ${IFACE} | grep "MHz \[${CHANNEL}\]")
    [[ -z "${CHANNEL_INFO}" ]] && return 1
    [[ "${CHANNEL_INFO}" == *no\ IR* ]] && return 1
    [[ "${CHANNEL_INFO}" == *disabled* ]] && return 1
    return 0
    else
    CHANNEL=$(printf '%02d' ${CHANNEL})
    CHANNEL_INFO=$(iwlist ${IFACE} channel | grep "Channel ${CHANNEL} :")
    [[ -z "${CHANNEL_INFO}" ]] && return 1
    return 0
    fi
    is_wifi_connected() {
    if [[ $USE_IWCONFIG -eq 0 ]]; then
    iw dev "$1" link 2>&1 | grep -E '^Connected to' > /dev/null 2>&1 && return 0
    else
    iwconfig "$1" 2>&1 | grep -E 'Access Point: [0-9a-fA-F]{2}:' > /dev/null 2>&1 && return 0
    fi
    return 1
    get_macaddr() {
    ip link show "$1" | grep ether | grep -Eo '([0-9a-f]{2}:){5}[0-9a-f]{2}[[:space:]]' | tr -d '[[:space:]]'
    get_avail_bridge() {
    for i in {0..100}; do
    curr_bridge=$(brctl show | grep "br$i" | cut -s -f1)
    if [[ -z $curr_bridge ]]; then
    echo "br$i"
    return
    fi
    done
    get_new_macaddr() {
    OLDMAC=$(get_macaddr "$1")
    for i in {20..255}; do
    NEWMAC="${OLDMAC%:*}:$(printf %02x $i)"
    (ip link | grep "ether ${NEWMAC}" > /dev/null 2>&1) || break
    done
    echo $NEWMAC
    ADDED_UNMANAGED=0
    NETWORKMANAGER_CONF=/etc/NetworkManager/NetworkManager.conf
    NM_OLDER_VERSION=1
    networkmanager_exists() {
    which nmcli > /dev/null 2>&1 || return 1
    NM_VER=$(nmcli -v | grep -m1 -oE '[0-9]+(\.[0-9]+)*\.[0-9]+')
    version_cmp $NM_VER 0.9.10
    if [[ $? -eq 1 ]]; then
    NM_OLDER_VERSION=1
    else
    NM_OLDER_VERSION=0
    fi
    return 0
    networkmanager_is_running() {
    networkmanager_exists || return 1
    if [[ $NM_OLDER_VERSION -eq 1 ]]; then
    NMCLI_OUT=$(nmcli -t -f RUNNING nm)
    else
    NMCLI_OUT=$(nmcli -t -f RUNNING g)
    fi
    [[ "$NMCLI_OUT" == "running" ]]
    networkmanager_iface_is_unmanaged() {
    nmcli -t -f DEVICE,STATE d | grep -E "^$1:unmanaged$" > /dev/null 2>&1
    ADDED_UNMANAGED=
    networkmanager_add_unmanaged() {
    networkmanager_exists || return 1
    [[ -d ${NETWORKMANAGER_CONF%/*} ]] || mkdir -p ${NETWORKMANAGER_CONF%/*}
    [[ -f ${NETWORKMANAGER_CONF} ]] || touch ${NETWORKMANAGER_CONF}
    if [[ $NM_OLDER_VERSION -eq 1 ]]; then
    if [[ -z "$2" ]]; then
    MAC=$(get_macaddr "$1")
    else
    MAC="$2"
    fi
    [[ -z "$MAC" ]] && return 1
    fi
    UNMANAGED=$(grep -m1 -Eo '^unmanaged-devices=[[:alnum:]:;,-]*' /etc/NetworkManager/NetworkManager.conf | sed 's/unmanaged-devices=//' | tr ';,' ' ')
    WAS_EMPTY=0
    [[ -z "$UNMANAGED" ]] && WAS_EMPTY=1
    for x in $UNMANAGED; do
    [[ $x == "mac:${MAC}" ]] && return 2
    [[ $NM_OLDER_VERSION -eq 0 && $x == "interface-name:${1}" ]] && return 2
    done
    if [[ $NM_OLDER_VERSION -eq 1 ]]; then
    UNMANAGED="${UNMANAGED} mac:${MAC}"
    else
    UNMANAGED="${UNMANAGED} interface-name:${1}"
    fi
    UNMANAGED=$(echo $UNMANAGED | sed -e 's/^ //')
    UNMANAGED="${UNMANAGED// /;}"
    UNMANAGED="unmanaged-devices=${UNMANAGED}"
    if ! grep -E '^\[keyfile\]' ${NETWORKMANAGER_CONF} > /dev/null 2>&1; then
    echo -e "\n\n[keyfile]\n${UNMANAGED}" >> ${NETWORKMANAGER_CONF}
    elif [[ $WAS_EMPTY -eq 1 ]]; then
    sed -e "s/^\(\[keyfile\].*\)$/\1\n${UNMANAGED}/" -i ${NETWORKMANAGER_CONF}
    else
    sed -e "s/^unmanaged-devices=.*/${UNMANAGED}/" -i ${NETWORKMANAGER_CONF}
    fi
    ADDED_UNMANAGED="${ADDED_UNMANAGED} ${1} "
    return 0
    networkmanager_rm_unmanaged() {
    networkmanager_exists || return 1
    [[ ! -f ${NETWORKMANAGER_CONF} ]] && return 1
    if [[ $NM_OLDER_VERSION -eq 1 ]]; then
    if [[ -z "$2" ]]; then
    MAC=$(get_macaddr "$1")
    else
    MAC="$2"
    fi
    [[ -z "$MAC" ]] && return 1
    fi
    UNMANAGED=$(grep -m1 -Eo '^unmanaged-devices=[[:alnum:]:;,-]*' /etc/NetworkManager/NetworkManager.conf | sed 's/unmanaged-devices=//' | tr ';,' ' ')
    [[ -z "$UNMANAGED" ]] && return 1
    [[ -n "$MAC" ]] && UNMANAGED=$(echo $UNMANAGED | sed -e "s/mac:${MAC}\( \|$\)//g")
    UNMANAGED=$(echo $UNMANAGED | sed -e "s/interface-name:${1}\( \|$\)//g")
    UNMANAGED=$(echo $UNMANAGED | sed -e 's/ $//')
    if [[ -z "$UNMANAGED" ]]; then
    sed -e "/^unmanaged-devices=.*/d" -i ${NETWORKMANAGER_CONF}
    else
    UNMANAGED="${UNMANAGED// /;}"
    UNMANAGED="unmanaged-devices=${UNMANAGED}"
    sed -e "s/^unmanaged-devices=.*/${UNMANAGED}/" -i ${NETWORKMANAGER_CONF}
    fi
    ADDED_UNMANAGED="${ADDED_UNMANAGED/ ${1} /}"
    return 0
    networkmanager_rm_unmanaged_if_needed() {
    [[ $ADDED_UNMANAGED =~ .*\ ${1}\ .* ]] && networkmanager_rm_unmanaged ${1}
    networkmanager_wait_until_unmanaged() {
    networkmanager_is_running || return 1
    while ! networkmanager_iface_is_unmanaged "$1"; do
    sleep 1
    done
    sleep 2
    return 0
    CHANNEL=1
    GATEWAY=192.168.12.1
    WPA_VERSION=1+2
    ETC_HOSTS=0
    HIDDEN=0
    SHARE_METHOD=nat
    IEEE80211N=0
    HT_CAPAB='[HT40+]'
    DRIVER=nl80211
    NO_VIRT=0
    CONFDIR=
    WIFI_IFACE=
    VWIFI_IFACE=
    INTERNET_IFACE=
    BRIDGE_IFACE=
    OLD_IP_FORWARD=
    OLD_BRIDGE_IPTABLES=
    OLD_MACADDR=
    cleanup() {
    trap "" SIGINT
    echo
    echo "Doing cleanup..."
    # exiting
    for x in $CONFDIR/*.pid; do
    # even if the $CONFDIR is empty, the for loop will assign
    # a value in $x. so we need to check if the value is a file
    [[ -f $x ]] && kill -9 $(cat $x)
    done
    rm -rf $CONFDIR
    if [[ "$SHARE_METHOD" != "none" ]]; then
    if [[ "$SHARE_METHOD" == "nat" ]]; then
    iptables -t nat -D POSTROUTING -o ${INTERNET_IFACE} -j MASQUERADE > /dev/null 2>&1
    iptables -D FORWARD -i ${WIFI_IFACE} -s ${GATEWAY%.*}.0/24 -j ACCEPT > /dev/null 2>&1
    iptables -D FORWARD -i ${INTERNET_IFACE} -d ${GATEWAY%.*}.0/24 -j ACCEPT > /dev/null 2>&1
    [[ -n $OLD_IP_FORWARD ]] && echo $OLD_IP_FORWARD > /proc/sys/net/ipv4/ip_forward
    elif [[ "$SHARE_METHOD" == "bridge" ]]; then
    ip link set down $BRIDGE_IFACE
    brctl delbr $BRIDGE_IFACE
    [[ -n $OLD_BRIDGE_IPTABLES ]] && echo $OLD_BRIDGE_IPTABLES > /proc/sys/net/bridge/bridge-nf-call-iptables
    fi
    fi
    if [[ "$SHARE_METHOD" != "bridge" ]]; then
    iptables -D INPUT -p tcp -m tcp --dport 53 -j ACCEPT > /dev/null 2>&1
    iptables -D INPUT -p udp -m udp --dport 53 -j ACCEPT > /dev/null 2>&1
    iptables -D INPUT -p udp -m udp --dport 67 -j ACCEPT > /dev/null 2>&1
    fi
    if [[ $NO_VIRT -eq 0 ]]; then
    if [[ -n $VWIFI_IFACE ]]; then
    ip link set down dev ${VWIFI_IFACE}
    ip addr flush ${VWIFI_IFACE}
    networkmanager_rm_unmanaged_if_needed ${VWIFI_IFACE} ${OLD_MACADDR}
    iw dev ${VWIFI_IFACE} del
    fi
    else
    ip link set down dev ${WIFI_IFACE}
    ip addr flush ${WIFI_IFACE}
    networkmanager_rm_unmanaged_if_needed ${WIFI_IFACE}
    fi
    die() {
    [[ -n "$1" ]] && echo -e "\nERROR: $1\n" >&2
    cleanup
    exit 1
    clean_exit() {
    cleanup
    exit 0
    # if the user press ctrl+c then execute die()
    trap "die" SIGINT
    ARGS=$(getopt -o hc:w:g:dnm: -l "help","hidden","ieee80211n","ht_capab:","driver:","no-virt" -n $(basename $0) -- "$@")
    [[ $? -ne 0 ]] && exit 1
    eval set -- "$ARGS"
    while :; do
    case "$1" in
    -h|--help)
    usage >&2
    exit 1
    --hidden)
    shift
    HIDDEN=1
    -c)
    shift
    CHANNEL="$1"
    shift
    -w)
    shift
    WPA_VERSION="$1"
    shift
    -g)
    shift
    GATEWAY="$1"
    shift
    -d)
    shift
    ETC_HOSTS=1
    -n)
    shift
    SHARE_METHOD=none
    -m)
    shift
    SHARE_METHOD="$1"
    shift
    --ieee80211n)
    shift
    IEEE80211N=1
    --ht_capab)
    shift
    HT_CAPAB="$1"
    shift
    --driver)
    shift
    DRIVER="$1"
    shift
    --no-virt)
    shift
    NO_VIRT=1
    shift
    break
    esac
    done
    if [[ $# -lt 1 ]]; then
    usage >&2
    exit 1
    fi
    if [[ $(id -u) -ne 0 ]]; then
    echo "You must run it as root." >&2
    exit 1
    fi
    WIFI_IFACE=$1
    if ! is_wifi_interface ${WIFI_IFACE}; then
    echo "ERROR: '${WIFI_IFACE}' is not a WiFi interface" >&2
    exit 1
    fi
    if ! can_have_ap ${WIFI_IFACE}; then
    echo "ERROR: Your adapter does not support AP (master) mode" >&2
    exit 1
    fi
    if ! can_have_sta_and_ap ${WIFI_IFACE}; then
    if is_wifi_connected ${WIFI_IFACE}; then
    echo "ERROR: Your adapter can not be connected to an AP and at the same time transmit as an AP" >&2
    exit 1
    elif [[ $NO_VIRT -eq 0 ]]; then
    echo "WARN: Your adapter does not fully support AP virtual interface, enabling --no-virt" >&2
    NO_VIRT=1
    fi
    fi
    if [[ "$SHARE_METHOD" != "nat" && "$SHARE_METHOD" != "bridge" && "$SHARE_METHOD" != "none" ]]; then
    echo "ERROR: Wrong Internet sharing method" >&2
    echo
    usage >&2
    exit 1
    fi
    if [[ "$SHARE_METHOD" == "bridge" ]]; then
    OLD_BRIDGE_IPTABLES=$(cat /proc/sys/net/bridge/bridge-nf-call-iptables)
    BRIDGE_IFACE=$(get_avail_bridge)
    if [[ -z $BRIDGE_IFACE ]]; then
    echo "ERROR: No availabe bridges < br100" >&2
    exit 1
    fi
    elif [[ "$SHARE_METHOD" == "nat" ]]; then
    OLD_IP_FORWARD=$(cat /proc/sys/net/ipv4/ip_forward)
    fi
    if [[ "$SHARE_METHOD" != "none" ]]; then
    MIN_REQUIRED_ARGS=2
    else
    MIN_REQUIRED_ARGS=1
    fi
    if [[ $# -gt $MIN_REQUIRED_ARGS ]]; then
    if [[ "$SHARE_METHOD" != "none" ]]; then
    if [[ $# -ne 3 && $# -ne 4 ]]; then
    usage >&2
    exit 1
    fi
    INTERNET_IFACE=$2
    SSID=$3
    PASSPHRASE=$4
    else
    if [[ $# -ne 2 && $# -ne 3 ]]; then
    usage >&2
    exit 1
    fi
    SSID=$2
    PASSPHRASE=$3
    fi
    else
    if [[ "$SHARE_METHOD" != "none" ]]; then
    if [[ $# -ne 2 ]]; then
    usage >&2
    exit 1
    fi
    INTERNET_IFACE=$2
    fi
    if tty -s; then
    read -p "SSID: " SSID
    while :; do
    read -p "Passphrase: " -s PASSPHRASE
    echo
    read -p "Retype passphrase: " -s PASSPHRASE2
    echo
    if [[ "$PASSPHRASE" != "$PASSPHRASE2" ]]; then
    echo "Passphrases do not match."
    else
    break
    fi
    done
    else
    read SSID
    read PASSPHRASE
    fi
    fi
    if [[ $NO_VIRT -eq 1 && "$WIFI_IFACE" == "$INTERNET_IFACE" ]]; then
    echo -n "ERROR: You can not share your connection from the same" >&2
    echo " interface if you are using --no-virt option." >&2
    exit 1
    fi
    CONFDIR=$(mktemp -d /tmp/create_ap.${WIFI_IFACE}.conf.XXXXXXXX)
    echo "Config dir: $CONFDIR"
    if [[ $NO_VIRT -eq 0 ]]; then
    VWIFI_IFACE=${WIFI_IFACE}ap
    # in NetworkManager 0.9.10 and above we can set the interface as unmanaged without
    # the need of MAC address, so we set it before we create the virtual interface.
    if networkmanager_is_running && [[ $NM_OLDER_VERSION -eq 0 ]]; then
    echo -n "Network Manager found, set $1 as unmanaged device... "
    networkmanager_add_unmanaged ${VWIFI_IFACE}
    # do not call networkmanager_wait_until_unmanaged because interface does not
    # exist yet
    echo "DONE"
    fi
    WIFI_IFACE_CHANNEL=$(iw dev ${WIFI_IFACE} info | grep channel | awk '{print $2}')
    if [[ -n $WIFI_IFACE_CHANNEL && $WIFI_IFACE_CHANNEL -ne $CHANNEL ]]; then
    echo "hostapd will fail to use channel $CHANNEL because $WIFI_IFACE is already set to channel $WIFI_IFACE_CHANNEL, fallback to channel $WIFI_IFACE_CHANNEL."
    CHANNEL=$WIFI_IFACE_CHANNEL
    fi
    VIRTDIEMSG="Maybe your WiFi adapter does not fully support virtual interfaces.
    Try again with --no-virt."
    echo -n "Creating a virtual WiFi interface... "
    iw dev ${VWIFI_IFACE} del > /dev/null 2>&1
    if iw dev ${WIFI_IFACE} interface add ${VWIFI_IFACE} type __ap; then
    # now we can call networkmanager_wait_until_unmanaged
    networkmanager_is_running && [[ $NM_OLDER_VERSION -eq 0 ]] && networkmanager_wait_until_unmanaged ${VWIFI_IFACE}
    echo "${VWIFI_IFACE} created."
    else
    VWIFI_IFACE=
    die "$VIRTDIEMSG"
    fi
    OLD_MACADDR=$(get_macaddr ${VWIFI_IFACE})
    [[ ${OLD_MACADDR} == $(get_macaddr ${WIFI_IFACE}) ]] && NEW_MACADDR=$(get_new_macaddr ${VWIFI_IFACE})
    WIFI_IFACE=${VWIFI_IFACE}
    fi
    can_transmit_to_channel ${WIFI_IFACE} ${CHANNEL} || die "Your adapter can not transmit to channel ${CHANNEL}."
    if networkmanager_is_running && ! networkmanager_iface_is_unmanaged ${WIFI_IFACE}; then
    echo -n "Network Manager found, set $1 as unmanaged device... "
    networkmanager_add_unmanaged ${WIFI_IFACE}
    networkmanager_wait_until_unmanaged ${WIFI_IFACE}
    echo "DONE"
    fi
    [[ $HIDDEN -eq 1 ]] && echo "Access Point's SSID is hidden!"
    # hostapd config
    cat << EOF > $CONFDIR/hostapd.conf
    ssid=${SSID}
    interface=${WIFI_IFACE}
    driver=${DRIVER}
    hw_mode=g
    channel=${CHANNEL}
    ctrl_interface=$CONFDIR/hostapd_ctrl
    ctrl_interface_group=0
    ignore_broadcast_ssid=$HIDDEN
    EOF
    if [[ $IEEE80211N -eq 1 ]]; then
    cat << EOF >> $CONFDIR/hostapd.conf
    ieee80211n=1
    wmm_enabled=1
    ht_capab=${HT_CAPAB}
    EOF
    fi
    if [[ -n "$PASSPHRASE" ]]; then
    [[ "$WPA_VERSION" == "1+2" || "$WPA_VERSION" == "2+1" ]] && WPA_VERSION=3
    cat << EOF >> $CONFDIR/hostapd.conf
    wpa=${WPA_VERSION}
    wpa_passphrase=$PASSPHRASE
    wpa_key_mgmt=WPA-PSK
    wpa_pairwise=TKIP CCMP
    rsn_pairwise=CCMP
    EOF
    fi
    if [[ "$SHARE_METHOD" == "bridge" ]]; then
    echo "bridge=${BRIDGE_IFACE}" >> $CONFDIR/hostapd.conf
    else
    # dnsmasq config (dhcp + dns)
    DNSMASQ_VER=$(dnsmasq -v | grep -m1 -oE '[0-9]+(\.[0-9]+)*\.[0-9]+')
    version_cmp $DNSMASQ_VER 2.63
    if [[ $? -eq 1 ]]; then
    DNSMASQ_BIND=bind-interfaces
    else
    DNSMASQ_BIND=bind-dynamic
    fi
    cat << EOF > $CONFDIR/dnsmasq.conf
    interface=${WIFI_IFACE}
    ${DNSMASQ_BIND}
    dhcp-range=${GATEWAY%.*}.1,${GATEWAY%.*}.254,255.255.255.0,24h
    dhcp-option=option:router,${GATEWAY}
    EOF
    [[ $ETC_HOSTS -eq 0 ]] && echo no-hosts >> $CONFDIR/dnsmasq.conf
    fi
    # initialize WiFi interface
    if [[ $NO_VIRT -eq 0 && -n "$NEW_MACADDR" ]]; then
    ip link set dev ${WIFI_IFACE} address ${NEW_MACADDR} || die "$VIRTDIEMSG"
    fi
    ip link set down dev ${WIFI_IFACE} || die "$VIRTDIEMSG"
    ip addr flush ${WIFI_IFACE} || die "$VIRTDIEMSG"
    if [[ "$SHARE_METHOD" != "bridge" ]]; then
    ip link set up dev ${WIFI_IFACE} || die "$VIRTDIEMSG"
    ip addr add ${GATEWAY}/24 broadcast ${GATEWAY%.*}.255 dev ${WIFI_IFACE} || die "$VIRTDIEMSG"
    fi
    # enable Internet sharing
    if [[ "$SHARE_METHOD" != "none" ]]; then
    echo "Sharing Internet using method: $SHARE_METHOD"
    if [[ "$SHARE_METHOD" == "nat" ]]; then
    iptables -t nat -I POSTROUTING -o ${INTERNET_IFACE} -j MASQUERADE || die
    iptables -I FORWARD -i ${WIFI_IFACE} -s ${GATEWAY%.*}.0/24 -j ACCEPT || die
    iptables -I FORWARD -i ${INTERNET_IFACE} -d ${GATEWAY%.*}.0/24 -j ACCEPT || die
    echo 1 > /proc/sys/net/ipv4/ip_forward || die
    elif [[ "$SHARE_METHOD" == "bridge" ]]; then
    # disable iptables rules for bridged interfaces
    echo 0 > /proc/sys/net/bridge/bridge-nf-call-iptables || die
    # create and initialize bridged interface
    brctl addbr ${BRIDGE_IFACE} || die
    brctl addif ${BRIDGE_IFACE} ${INTERNET_IFACE} || die
    ip link set dev ${BRIDGE_IFACE} up || die
    fi
    else
    echo "No Internet sharing"
    fi
    # boost low-entropy
    if [[ $(cat /proc/sys/kernel/random/entropy_avail) -lt 1000 ]]; then
    which haveged > /dev/null 2>&1 && {
    haveged -w 1024 -p $CONFDIR/haveged.pid
    fi
    # start dns + dhcp server
    if [[ "$SHARE_METHOD" != "bridge" ]]; then
    iptables -I INPUT -p tcp -m tcp --dport 53 -j ACCEPT || die
    iptables -I INPUT -p udp -m udp --dport 53 -j ACCEPT || die
    iptables -I INPUT -p udp -m udp --dport 67 -j ACCEPT || die
    dnsmasq -C $CONFDIR/dnsmasq.conf -x $CONFDIR/dnsmasq.pid || die
    fi
    # start access point
    echo "hostapd command-line interface: hostapd_cli -p $CONFDIR/hostapd_ctrl"
    # from now on we exit with 0 on SIGINT
    trap "clean_exit" SIGINT
    if ! hostapd $CONFDIR/hostapd.conf; then
    echo -e "\nError: Failed to run hostapd, maybe a program is interfering." >&2
    if networkmanager_is_running; then
    echo "If an error like 'n80211: Could not configure driver mode' was thrown" >&2
    echo "try running the following before starting create_ap:" >&2
    if [[ $NM_OLDER_VERSION -eq 1 ]]; then
    echo " nmcli nm wifi off" >&2
    else
    echo " nmcli r wifi off" >&2
    fi
    echo " rfkill unblock wlan" >&2
    fi
    die
    fi
    clean_exit
    Last edited by OBLiQUE (2014-09-02 20:26:22)

    adam777 wrote:
    Thank, just what I was looking for.
    Unfortunately, it seems that currently my Intel 5300 card (using the iwlwifi driver), does not support AP mode.
    From what I understand, hostapd can be used in bridge mode as well, which should have no compatibility problems.
    Can some one point me in the right direction?
    * EDIT *
    After more attempts, I think I got it wrong and AP mode is indeed required.
    Sorry for the late reply, I didn't noticed your message.. Did you got any errors? I have Intel 6205 and it works.
    Also if you use NetworkManager, then you have to say to NetworkManager to stop using your interface.
    You can do it by editing the /etc/NetworkManager/NetworkManager.conf file and put the following (without the <>):
    [keyfile]
    unmanaged-devices=mac:<interface's mac address here>
    and restart your NetworkManager. Ofcourse after you finish, you have to remove it in order to get your wifi back to working with NetworkManager.

  • New rc.conf and bridges

    hi,
    I've been running an OpenVPN Server on my Arch on a bridged interface for quite a while and it worked perfectly fine. I used this Wiki entry to configure the bridge: https://wiki.archlinux.org/index.php/OpenVPN_Bridge
    On my old setup, I had this config (basically as described on the Wiki):
    /etc/conf.d/bridges
    bridge_br0="tap0 eth0"
    BRIDGE_INTERFACES=(br0)
    /etc/rc.conf
    eth0="eth0 0.0.0.0 promisc up"
    tap0="tap0 0.0.0.0 promisc up"
    br0="br0 172.16.20.1 netmask 255.255.255.0 broadcast 172.16.20.255"
    INTERFACES=(eth0 tap0 br0)
    This obviously doesn't work anymore with the new rc.conf, because I cannot configure multiple interfaces in rc.conf anymore. Although the actual problem seems to be that the bridge isn't even created anymore at boot.
    So after some reading into netcfg I created the following network profile, which works fine:
    /etc/network.d/openvpn_bridge
    INTERFACE="br0"
    CONNECTION="bridge"
    DESCRIPTION="Ethernet/OpenVPN bridge"
    BRIDGE_INTERFACES="eth0 tap0"
    IP="static"
    ADDR="172.16.20.1"
    GATEWAY="172.16.20.254"
    DNS=("172.16.20.254")
    My actual question is: is this the proper way to do this or am I missing something here? and what about /etc/conf.d/bridges? As far as I can see, it is pretty much useless now (and therefore could be removed from bridge-utils). I just wanted to be sure, because I was planning to update the Wiki about this and couldn't find any other information about it.

    65kid wrote:
    hi,
    I've been running an OpenVPN Server on my Arch on a bridged interface for quite a while and it worked perfectly fine. I used this Wiki entry to configure the bridge: https://wiki.archlinux.org/index.php/OpenVPN_Bridge
    On my old setup, I had this config (basically as described on the Wiki):
    /etc/conf.d/bridges
    bridge_br0="tap0 eth0"
    BRIDGE_INTERFACES=(br0)
    /etc/rc.conf
    eth0="eth0 0.0.0.0 promisc up"
    tap0="tap0 0.0.0.0 promisc up"
    br0="br0 172.16.20.1 netmask 255.255.255.0 broadcast 172.16.20.255"
    INTERFACES=(eth0 tap0 br0)
    This obviously doesn't work anymore with the new rc.conf, because I cannot configure multiple interfaces in rc.conf anymore. Although the actual problem seems to be that the bridge isn't even created anymore at boot.
    So after some reading into netcfg I created the following network profile, which works fine:
    /etc/network.d/openvpn_bridge
    INTERFACE="br0"
    CONNECTION="bridge"
    DESCRIPTION="Ethernet/OpenVPN bridge"
    BRIDGE_INTERFACES="eth0 tap0"
    IP="static"
    ADDR="172.16.20.1"
    GATEWAY="172.16.20.254"
    DNS=("172.16.20.254")
    My actual question is: is this the proper way to do this or am I missing something here? and what about /etc/conf.d/bridges? As far as I can see, it is pretty much useless now (and therefore could be removed from bridge-utils). I just wanted to be sure, because I was planning to update the Wiki about this and couldn't find any other information about it.
    Thank you!  Your post cured the headache I had given myself by trying to write a script to do this for Virtualbox having unsuccessfully fumbled with the current bridging documentation in the wiki.

  • Bridge network with Virtualbox

    howdy guys,
    I've been playing with virtualbox a little bit, and found the blog of a guy who is using a virtualbox vm as a webserver.
    he lists these steps:
    tunctl -t tap0 -u user
    ;(where user is the user who runs VirtualBox)
    chmod 666 /dev/net/tun
    ;(or add user running VirtualBox to the 'tun' group, on MDV)
    brctl addbr br0
    ifconfig eth0 0.0.0.0 promisc
    ;(where eth0 is the interface to be bridged)
    brctl addif br0 eth0
    dhclient br0
    brctl addif br0 tap0
    ifconfig tap0 192.168.1.50 up
    ;(where 192.168.1.50 is an arbitrary unused
    ;IP in the same subnet as your local network)
    echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp
    route add -host 192.168.1.5 dev tap0
    ;(where 192.168.1.5 is the IP address of the host machine)
    arp -Ds 192.168.1.5 eth0 pub
    ;(where 192.168.1.5 is the IP address of the host machine)
    (from http://www.happyassassin.net/2007/02/06 … rtualbox/)
    I got brctl from the package "bridge-utils,"
    and tunctl from "uml_utilities."
    these steps almost work, except I can't use dhclient on br0, and on
    the host machine eth0 loses its address.
    Can someone give me some hints about how do accomplish this in an arch
    way, making use of /etc/conf.d/bridges, and rc.conf, or whatever?  thanks.

    Hi kant1. First I want to thank you for taking the time to respond and second I apologize for not posting earlier. I have been away from my computer these 2 days.
    Now,  to answer your questions:
    Have you tried running "top" and then running openoffice/xine?  Maybe they are using some other program that is getting hung up on the network change?
    I don't see anything strange.
    Also, did you try rebooting after making these changes?
    Yes, more than once
    Are you using the same address for the bridge as you are for your regular connection?  Or using dhcp for both?  (The link I posted uses dhcp, but you may need to specify the address if that's what you do for your regular connection)
    Does "ifconfig" show that eth0 (or whatever your regular ethernet connection is) does not have an ip address, but br0 does?  Does "brctl show" show that br0 has eth0 attached as an interface?
    Here is my ifconfig output. I believe this is how it should be
    $ ifconfig
    br0 Link encap:Ethernet HWaddr 00:17:31:83:C2:30
    inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:1307 errors:0 dropped:0 overruns:0 frame:0
    TX packets:1394 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:1021200 (997.2 Kb) TX bytes:195531 (190.9 Kb)
    eth0 Link encap:Ethernet HWaddr 00:17:31:83:C2:30
    UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
    RX packets:1307 errors:0 dropped:0 overruns:0 frame:0
    TX packets:1370 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:1041405 (1016.9 Kb) TX bytes:206215 (201.3 Kb)
    Interrupt:18
    lo Link encap:Local Loopback
    inet addr:127.0.0.1 Mask:255.0.0.0
    UP LOOPBACK RUNNING MTU:16436 Metric:1
    RX packets:129 errors:0 dropped:0 overruns:0 frame:0
    TX packets:129 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:8243 (8.0 Kb) TX bytes:8243 (8.0 Kb)
    and this is "brctl show"
    $ brctl show
    bridge name bridge id STP enabled interfaces
    br0 8000.00173183c230 no eth0
    and this is my network section in /etc/rc.conf
    lo="lo 127.0.0.1"
    BRIDGE_INTERFACES=(br0)
    bridge_br0=(eth0)
    br0="br0 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255"
    eth0="eth0 0.0.0.0 promisc"
    #eth0="eth0 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255"
    INTERFACES=(lo br0 eth0)
    # Routes to start at boot-up (in this order)
    # Declare each route then list in ROUTES
    # - prefix an entry in ROUTES with a ! to disable it
    gateway="default gw 192.168.1.1"
    ROUTES=(gateway)
    I don't know if it has any relevance but I was trying to see what is happening with wireshark. When I try to run soffice I see DNS queries to my ISP about arch.localdomain. These queries have naturally response "not found". arch is my host name.
    UPDATE: After posting this i added this line in /etc/hosts.
    127.0.0.1 arch.localdomain arch
    and now openoffice works again .
    But now I have 2 problems less significant
    1. Still xine doesn't work. I see a query for eth0.localdomain
    2. If I use the "Alt+F2" box in KDE and type i.e. calc it will still query my ISP for calc.localdomain.
    Last edited by insane (2007-06-16 14:14:21)

  • How to bridge two interfaces on same motherboard.

    Hello everyone, I've just started digging in to Arch Linux, and I am loving it so far!
    Most of my Linux experience is from Ubuntu, so bear with me here, because I'm having a fairly simple problem that I had figured out on Ubuntu and would like to reproduce on Arch.
    I have a motherboard with two network cards in it.   One is fed from the router, and the other one feeds an Xbox1 that runs Xbox Media Center.   Both of these machines are set to DHCP for the network.  What I need from the setup is for each machine to get its own internal IP from the router's dhcp server.  In Ubuntu I had this setup and working perfectly by having the following code in my /etc/network/interfaces file:
    auto lo
    iface lo inet loopback
    auto eth0
    auto br0
    iface eth1 inet dhcp
    iface br0 inet dhcp
    bridge_ports eth0 eth1
    My problem is that I do not have a /etc/network/interfaces file in Arch, like there is in Ubuntu.    Where would I need to input these commands?
    In Arch I have installed the bridge-utils package, and last night I installed networkmanager, and dnsmasq.   In my rc.conf file I commented out the network commands, and the network daemon, and added networkmanager's daemon to the list.   Something tells me this wasn't necessary, and I can remove all of that if its necessary to get the bridge up.   This isn't as simple as me just making my own /etc/network/interfaces file is it?   
    Anyway thanks for taking the time to read over this.   Let me know if there is some pertinent information I've left out of this post.   I've tried to be as clear as I can be.

    Ah thank you very much for pointing me in the right direction!   I read over man brctl, studied the /etc/conf./bridges and the /etc/rc.conf files and figured it out!  Here is what I did, in the hopes it might help someone else out.
    First off I removed the networkmanager app, as it wasn't necessary at all.  After I removed that I made sure to remove the deamon from rc.conf, and uncommented the daemon for 'network'. 
    in the file /etc/rc.conf I added the following in between the HOSTNAME and the gateway line:
    eth0="eth0 up"
    eth0="eth1 up"
    br0="dhcp"
    INTERFACES=(lo eth0 eth1 br0)
    In the /etc/conf.d/bridges file I added the following two lines:
    bridge_br0="eth0 eth1"
    BRIDGE_INTERFACES=(br0)
    When I logged back in the PC had an IP and so did the Xbox!   Thanks again for the help.  This was the one big hurdles I had to adopting Arch.
    Last edited by Beelzebud (2010-07-16 09:03:42)

  • Want to create 2 wireless networks: b/g and n

    I just had a wonky 1st gen time capsule replaced (my iMac also decided to need a total system restore as the thing was dying - cue total panic and a Backblaze subscription, and two external hard drives with redundant backups of family photos!).  What finally prompted the replacement was the total collapse of our wireless network - Airport Utility unable to pick up TC or AE, Apple TV couldn't see networks (all the data storage issues came just as I was about to put the replacement TC in), none of the computers would remember the wireless networks, constantly asking for passwords.
    I was having a lot of the same set up issues with the new TC when I decided to set it to 802.11n only.  Problem solved. Instantly.  Worked perfectly.  I assumed I'd be running at n speeds as I *thought* all our devices were n.  I didn't realize our two iPhones (3G and 3Gs) were basically keeping us stuck in 2.4 territory. 
    Which left the problem of not having WiFi for our iPhones (which we'd  use a lot).  i realized I had an old b/g only AE. 
    So - I've set up the following:
    DSL modem ethernet to TC (note the replacement is still a first gen - I can't do dual band)
    AE b/g ethernet to TC
    TC created wireless network named Red
    AE b/g created wireless network named Blue.  Only way I could get this to work was by putting it in bridge mode.  Otherwise it was ******** about ip addresses. This seems to work.
    I also have a newer AE (802.11n) in my office upstairs which I use to boost signal and connect a printer.  This seems to drop in an out of even being visible in Airport Utility (which may have something to do with the fact that it's sitting next to the old TC which is s l o w l y erasing - maybe causing interference?). 
    I set this newer AE up to join existing wireless network Red.  Which it did fine...but it wanted to be in bridge mode too...which is NOT how it worked before (without the b/g AE wired to the TC).  What should the settings be on the newer AE?  I want it to be in the Red network (n) so we can share my office printer, etc. 
    Any advice appreciated.

    I noticed the massive improvement when I went to the 5GHz band, so I think I'd prefer to keep it there - I honestly don't care about the speed in n - it just seems that something - possibly even our fireplace, was causing so much interference at 2.4 GHz.
    The 802.11n AX seems to be showing up fine now that my old TC has been packed in a box and sent back to Apple, so I think I've managed it.  Could the old TC have really interfered to that extent?  I also think the fact that I forgot to turn on the printer attached to the 802.11n AX might have been impeding my print performance on the network. LOL. Sorry to waste your time!
    I probably don't *need* to extend the range of the TC - it's really more to enable printing (I know there are other ways to accomplish this - but this is a bit easier when our au pair - who uses a pc - wants to print).  The 802.11n AX is probably about 20ish feet away from the TC - would that present a problem in the 5GHz range?

Maybe you are looking for