2

I would like to have both a static IP or two (different locally routable subnets) and a DHCP virtual interface on a single physical wireless NIC.

Any suggestion on how to address that?

Ubuntu 12.04LTS, Lenovo T61

TIA!

jcoats
  • 41

1 Answers1

5

I'm assuming you're running NetworkManager here, you've already set up your wireless connection using DHCP and you're talking about IPv4 here.

While you can't configure the static addresses in NetworkManager GUI, there's a hack possible.

  1. Find the connection UUID of the connection configured

    $ nmcli con
    
  2. Add a script in /etc/NetworkManager/dispatcher.d/, containing this starting point:

    #!/bin/bash
    
    WLAN_DEV=wlan0
    MYCON_UUID=31c48409-e77a-46e0-8cdc-f4c04b978901
    
    if [ "$CONNECTION_UUID" == "$MYCON_UUID" ]; then
        # add alias for Network 1: 192.168.0.123/24
        ifconfig $WLAN_DEV:0 192.168.0.123 netmask 255.255.255.0 up
        # add alias for Network 2: 192.168.1.123/24
        ifconfig $WLAN_DEV:1 192.168.1.123 netmask 255.255.255.0 up
    fi
    
  3. Make sure it has the right permissions (chmod +x /path/to/script.sh) and restart NetworkManager:

    $ sudo service network-manager restart
    

Now when you connect to your wireless connection, it should add the two aliases (check with ifconfig.

gertvdijk
  • 67,947