Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.