Issue with setting up multiple IP addresses on Ubuntu Server

16,049

Solution 1

It has been a long time since I posted this question. While I never got around to configuring the old server with multiple addresses, the following is a working configuration I'm using on a different server currently.

auto eth0
iface eth0 inet static
        address 172.16.100.125
        netmask 255.255.255.0
        network 172.16.100.0
        broadcast 172.16.100.255
        gateway 172.16.100.1
        dns-nameservers 172.16.100.221 208.67.222.222

auto eth0:0
iface eth0:0 inet static
name Ethernet alias LAN card
        address 172.16.100.123
        netmask 255.255.255.0
        network 172.16.100.0
        broadcast 172.16.100.255
        gateway 172.16.100.1

Solution 2

An alias interface should not have a gateway.

https://wiki.debian.org/NetworkConfiguration#Multiple_IP_addresses_on_One_Interface

Share:
16,049

Related videos on Youtube

varunyellina
Author by

varunyellina

Product Designer

Updated on September 18, 2022

Comments

  • varunyellina
    varunyellina over 1 year

    I want to set up two IP addresses on my system for access through LAN. This is my config on my other system.

    Desktop Installation

    My Connection Information

    My desktop installation runs with multiple IPs added through Network Manager both through LAN and wifi.

    Server Installation

    On my server install I've edited /etc/network/interfaces to the following:

    auto eth0
    auto eth0:1
    # IP-1
    iface eth0 inet static
    address 172.16.35.35
    network 172.16.34.1
    netmask 255.255.254.0
    broadcast 172.16.35.255
    dns-nameservers 172.16.100.221 8.8.8.8
    # IP-2
    iface eth0:1 inet static
    address 172.16.34.34
    network 172.16.34.1
    netmask 255.255.254.0
    gateway 172.16.34.1
    broadcast 172.16.35.255
    

    After restarting through /etc/init.d/networking restart I receive

    Failed to bring up eth0:1

    What am I doing wrong?

    • trognanders
      trognanders over 11 years
      There is a typo on the broadcast address of eth0, it should be 172.16.35.255 instead of 172.166.35.255. Other than that the config looks good. Try fixing the problem and seeing if the networking will reset. If not see if can find more details in the syslog, or dmesg.
    • varunyellina
      varunyellina over 11 years
      Bailey S: Sorry that was a typo here but it was fixed in the actual file.But to no avail i'm still getting "Failed to bring up eth0:1". How do i go about with syslog or dmesg
    • carestad
      carestad over 11 years
      @varunyellina Shouldn't network 172.16.34.1 be network 172.16.34.0?
    • Registered User
      Registered User over 10 years
      why dont you use GUI of Network Manager to do the same? you are trying to bring 2 different subnets on same NIC, i m surprised address of eth0 falls outside the range of subnet and still it is up
    • NGRhodes
      NGRhodes over 10 years
      Registered User, I guess the server install has no GUI.
    • peterretief
      peterretief about 8 years
      Why did you start at iface eth0:1 and not eth0:0, that might mess with things
  • varunyellina
    varunyellina over 10 years
    If you see my answer to the question, having a gateway on the alias interface didn't cause any issues for me. Hope i'm not wrong in an entirely different situation.