3/26/08

Adding ip address on trixbox[without X]

On Ubuntu, to manage ip address of the box in console, we need to edit /etc/network/interfaces. By default ubuntu is set to using dhcp as you will see.

auto eth0
iface eth0 inet dhcp

changing "dhcp" to "static" and add network information
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

will change the box to use static ip address. Adding more ip address on this interface can be done by add script below to the same "interfaces" file.[note that we have :1 after eth0]
auto eth0:1
iface eth0:1 inet static
address 192.168.1.109
netmask 255.255.255.0
broadcast 192.168.1.255

Trixbox use centos. Like other redhat family, it has system-config-network utility or if you want to play with the configuration file, adding ip address is done by create new file in /etc/sysconfig/network-scripts like in mycase. I have external static ip address define in ifcfg-eth0.
[trixbox1.localdomain ~]# cd /etc/sysconfig/network-scripts
[trixbox1.localdomain network-scripts]# ls ifcfg-eth0
ifcfg-eth0
[trixbox1.localdomain network-scripts]#

Now, I want to add new internal ip to this interface so I create a new file call "ifcfg-eth0:1" by copy from "ifcfg-eth0".
[trixbox1.localdomain network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1
[trixbox1.localdomain network-scripts]#

then modify "ifcfg-eth0:1" made it look like this.
[trixbox1.localdomain network-scripts]# cat ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=none
IPADDR=192.168.1.123
NETMASK=255.255.255.0
TYPE=Ethernet
[trixbox1.localdomain network-scripts]#

last restart network service and check the result.
[trixbox1.localdomain network-scripts]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
[trixbox1.localdomain network-scripts]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:E0:4C:84:26:BB
.....

eth0:1 Link encap:Ethernet HWaddr 00:E0:4C:84:26:BB
inet addr:192.168.1.123 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11 Base address:0xe000

lo Link encap:Local Loopback
.....

[trixbox1.localdomain network-scripts]#

0 comments: