2

In a lab setup, I want eth0 on a Ubuntu server box to get a DHCP address for talking to the outside world, and I also want to assign it a static 10.x.y.z address for talking to other boxes on the local network that have 10.x.y.z addresses. I want to do this by editing /etc/network/interfaces.

The man page for /etc/network/interfaces is modeled after "here's a bunch of examples, I hope you can figure out the actual rules on your own". I don't see a way to give one interface two addresses using two different methods (static and dhcp), and initial fumbling didn't produce useful results.

Paul Hoffman
  • 2,214
  • 5
  • 19
  • 23

2 Answers2

4

You use eth:N notation for that.

auto eth0
iface eth0 inet dhcp

auto eth0:0
iface eth0:0 inet static
        address 192.168.32.10
        netmask 255.255.255.0
Paul Hoffman
  • 2,214
  • 5
  • 19
  • 23
poige
  • 9,448
  • 2
  • 25
  • 52
1

ip can add multiple addresses to an interface.

iface eth0 inet dhcp
    up ip addr add 192.168.32.10/24 dev eth0
user1686
  • 10,162
  • 1
  • 26
  • 42