0

I recently deployed a VM with Ubuntu 15.10 and I am having trouble configuring the network properly. Note: When the OS was installed, it picked up an IP (from DHCP I guess), because it didn't ask me to set up the network. After installation I could access the server via that IP. However, I keep trying to add another IP (10.100.144.115) to the server and the server does not pick it up.

This is what I have on /etc/network/interfaces:

root@blah20:/etc/network# cat interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo ens33
iface lo inet loopback

# The primary network interface – use DHCP to find our address
auto ens33
iface ens33 inet static
address 10.100.144.142
netmask 255.255.255.0
broadcast 10.100.144.255
gateway 10.100.144.1
dns-nameserver 8.8.8.8

# The secondary IP – This one is very important as it hosts the Portal.
auto ens33
iface ens33:0 inet static
address 10.100.144.115
netmask 255.255.255.0
gateway 10.100.144.1
root@blah20:/etc/network#

When I restart the network, I only get the first IP.

root@blah20:/etc/network# ifconfig
ens33     Link encap:Ethernet  HWaddr 00:50:56:a4:5e:35
          inet addr:10.100.144.142  Bcast:10.100.144.255  Mask:255.255.255.0
          inet6 addr: fe80::250:56ff:fea4:5e35/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:482877 errors:2 dropped:2 overruns:0 frame:0
          TX packets:44446 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:108341017 (108.3 MB)  TX bytes:14661830 (14.6 MB)
          Interrupt:19 Base address:0x2000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1724 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1724 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:170653 (170.6 KB)  TX bytes:170653 (170.6 KB)

root@blah20:/etc/network#

I have tried different things but nothing seems to work. Can somebody tell me what I am doing wrong? I never had this issue with CentOS or any other flavor.

3
  • Are you trying to make a VLAN, or do you just want an interface to have two addresses? Jul 11, 2016 at 14:42
  • I just want to add another IP to the same interface where the Main IP is.
    – Web4Fun
    Jul 11, 2016 at 14:45
  • Then you don't need a separate stanza. You should be able to just add the address and netmask lines into the existing stanza. I'll test this out and report back. Jul 11, 2016 at 14:49

2 Answers 2

1

I think the problem is that you have auto ens33 again instead of auto ens33:0 in the second stanza. As it currently stands, your config should allow you to do ifup ens33:0 to start it manually.

1
  • I thought I tried this earlier but I didn't. After checking the file again and making the change, it seems to be picking it up. Thanks so much.
    – Web4Fun
    Jul 11, 2016 at 20:56
0

My comment above was incorrect; you do need two separate stanzas, but the interface name should be the same. Also, you don't need to have the auto twice.

Here's the corrected section of the file:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface – use DHCP to find our address
auto ens33
iface ens33 inet static
address 10.100.144.142
netmask 255.255.255.0
gateway 10.100.144.1
dns-nameserver 8.8.8.8

# The secondary IP – This one is very important as it hosts the Portal.
iface ens33 inet static
address 10.100.144.115
netmask 255.255.255.0

(The broadcast address, by default, is the last valid address, so it doesn't need to be explicitly stated.)

Note that you're not using DHCP anywhere here, so the first comment there is incorrect.

You can, optionally, combine the address and netmask lines by specifying the prefix after the address, like so:

# The primary network interface – use DHCP to find our address
auto ens33
iface ens33 inet static
address 10.100.144.142/24
gateway 10.100.144.1
dns-nameserver 8.8.8.8

# The secondary IP – This one is very important as it hosts the Portal.
iface ens33 inet static
address 10.100.144.115/24
8
  • Thanks. I tried both suggestions and it still didn't pick up the IP after I restarted the network. Any other ideas?
    – Web4Fun
    Jul 11, 2016 at 15:22
  • OK this is strange. If I restart the network, the additional IP won't get picked up. If I do ifup ens33:0, then the IP gets picked up. How can I make 10.100.144.115 to stay permanently bound to the server just like the main IP?
    – Web4Fun
    Jul 11, 2016 at 15:50
  • You shouldn't be using the :0 syntax at all. If you do sudo ifdown ens33 followed by sudo ifup ens33, then both addresses should be assigned to the interface. Jul 11, 2016 at 16:01
  • Can you please clarify where I shouldn't be using [:0]? Is it in the command line or in the interfaces file?
    – Web4Fun
    Jul 11, 2016 at 16:21
  • Both (command line and interface). Jul 11, 2016 at 16:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .