Hi
does anybody know how we can add more than one ip for NIC(in Redhat Linux 7.2)?
i usually do it by using this command
ifconfig eth0 add <ip addresss> netmask <..............> up
or ;
ip address add 192.168.20.1/24 dev eth0
or
adding it manually to file in /etc/sysconfig/network-scripts
but their is no ifcfg-eth0 !!!!!
-------------------------------------------------------------
and it works cuz i can ping it from another machine
BUT when i reboot the machine all of the are gone.
I'm looking for way that these IPs can remain on the interface even after
reboot or shut down
i found the file in /etc/sysconfig/networking/devices/ifcfg-eth0
and here i can add the new ip and after reboot everything is ok.
but i don't know how i can have it changed without rebooting and
more important that that i want to add more than one ip for this
interface.
Can anyone help me up?
What you need to do is to add an alias to the interface, in order to do that, do the following. First go to the file /etc/sysconfig/networking/devices/ifcfg-eth0 and add the following lines:
DEVICE=eth0:1
ONBOOT=yes
BOOTPROTO=static
IPADDR= xxx.xxx.xxx.xxx
NETMASK=xxx.xxx.xxx.xxx
GATEWAY=xxx.xxx.xxx.xxx
TYPE=Ethernet
USERCTL=no
NETWORK=xxx.xxx.xxx.xxx
BROADCAST=xxx.xxx.xxx.xxx
PEERDNS=no
Where xxx.xxx.xxx.xxx put the apropriate addresses for your computer. After doing so go to the directory /etc/rc.d/init.d and type ./network stop; ./network start. That will initiate the new configurations. You can add as many IP addresses as you want by just doing the procedures above and changing the DEVICE:eth0:x from 1 to 2,3,... etc. and also by changing the IP address.
You re wellcome. You can also add an alias to your interface with ifconfig. You can write ifconfig eth0:x <IP ADDRESS> netmask <NETMASK>. But then you must add with route a default gateway to your routing table for the new IP address.
Yeah after network stop and start the configurations are all gone. That's probably because ifconfig uses ioctl. I made a simple programm that uses ioctl for changing the IP, I can give it to you if you want, but after rebooting the new configurations are gone.
To tell you the truth I do not know why there are so many files doing the same thing. Probably because these configurations are vendor dependent. (Especially red hat tends to change everything, I still don't understand why they do not provide the kernel source code in /usr/src/linux)
The RedHat team uses a tool called linuxconf to configure the system, which is a control panel for all system services. Under te section Config/Networking/Server Tasks there is a line named IP Aliases for virtual hosts, where you can select the interface for which you want to make an alias. All you have to do is to add the IP address and the netmask and you're done. Changes are active just after reboot.
Yeah if you read the command above i think they work but maybe with a little bit of difference (see the man pages)
but the file you're looking for it to edit manually is not called (eth0)
I've forgotten the real name but ...
It should be something like prg0 or ....