You have a machine running ubuntu, NetworkManager gets the ip from a dhcp server and you want to have another ip that never changes on the same interface (for example if you want to also act as a dhcp server for your local network and both the local and uplink are connected on the same interface).
Dhclient seems to support this through an "alias" statement and NetworkManager seems to use dhclient but I just couldn't make it work like this.
Create a script in /etc/network/if-up.d/ . Name is asÂ you wish. My choice was "alias" .
- span style="color: #ff0000;">"$IFACE" != "lo"
Then make sure the script is executable:
You can replace the ip and mask to fit your needs.
NetworkManager will run this script automatically after it brings the interface up.
This worked for me but in the spirit of usability it would have been nice to have this kind of feature directly into NetworkManager's connection configuration gui.
Do you know any other way of doing this? Please share it in the comments.
2 thoughts on “Ip alias with dhcp in ubuntu”
I’m basing this on my experience with rhel/cent/fedora, but the networking uses the same components so it should work. It’s all at http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/s1-network-aliases.html, but this is the overview.
1. Open the system-config-network tool (System > Administration > Network)
2. Click “New” and add a device identical to the existing, using the same hardware, and setting the desired static IP info. It’ll be created with a suffix, like “etho:1”
3. Select the new device and click “Edit”, and make the following settings (click OK when done):
* Controlled by Network Manger: UNCHECKED
* Activate device when parent device starts: CHECKED
4. Click the “Activate” button, and save settings if prompted
==> Should bring the IP up, and automatically start it when eth0 is active.
The reason I did it my way is because I also wanted to restart the dhcp server and bind whenever this interface was active.
[rq=3993,0,blog][/rq]MYC4 bid Importer plugin