Different network alias ip on Ubuntu

1

I have an Ubuntu server with only one NIC and an address x.x.31.82 configured on it, the default gateway for it is x.x.31.81 and the mask is x.x.31.80/29.

The problem is that I'm trying to configure another address x.x.20.210 – the default gateway is supposed to be x.x.20.209 but I'm unable to configure it on the server.

After I've configured x.x.20.210 as an alias on the NIC, I've used the command

route add -net x.x.20.208 netmask 255.255.255.248 gw x.x.20.209

The route was added to the routing table but but I still can't access x.x.20.210 from the outside.

Can anybody help me please?

user1398932

Posted 2012-07-19T10:42:34.083

Reputation: 11

Answers

0

To use multiple IP on the same interface, the best way in my opinion is to add in /etc/network/interfaces something like that for the 2nd IP:

auto eth0:0
iface eth0:0 inet static
    address x.x.20.210
    netmask 255.255.255.0
    broadcast x.x.20.255
    network x.x.20.0
    gateway x.x.20.209

And you shouldn't need to configure a route manually. If you want to access it from the outside, don't forget to add this 2nd IP to /etc/hosts and if needed, to configure a DNS record for it.

laurent

Posted 2012-07-19T10:42:34.083

Reputation: 4 166