ifcfg-ethX voodoo for a second IP on the same interface

Ed Greshko Ed.Greshko at greshko.com
Sat Apr 21 05:05:16 UTC 2012


On 04/21/2012 12:55 PM, Tommy Pham wrote:
> On Fri, Apr 20, 2012 at 9:34 PM, Ed Greshko <Ed.Greshko at greshko.com> wrote:
>> On 04/21/2012 11:20 AM, Sam Varshavchik wrote:
>>> For testing purposes I need to add a second IP address to eth0.
>>>
>>> eth0 is managed by NetworkManager, and uses dhcp.
>>>
>>> I know that if I get rid of NetworkManager and put static IP addresses in
>>> ifcfg-eth0, I can also sprinkle some magic dust into ifcfg-eth0:1, and have the
>>> second IP address come up together with the first one.
>>>
>>> This does not seem to work with a NetworkManager-managed DHCP-based interface.
>>>
>>> Basically, is there some voodoo I can throw in a file somewhere that would perform
>>> the equivalent of:
>>>
>>> ip addr add 192.168.0.5 dev eth0 label eth0:1
>>>
>>> when eth0 comes up via DHCP, by NetworkManager?
>>>
>> Well.....  I think you can only do this with static IP addresses....
>>
>> But, all you have to do is modify /etc/sysconfig/network-scripts/ifcfg-whatever  to have
>>
>> IPADDR0=192.168.0.225
>> IPADDR1=192.168.0.226
>>
>> for example....
>>
>> Then you'd see...
>>
>> 2: p2p1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
>>    link/ether 08:00:27:36:bf:b0 brd ff:ff:ff:ff:ff:ff
>>    inet 192.168.0.225/24 brd 192.168.0.255 scope global p2p1
>>    inet 192.168.0.226/24 brd 192.168.0.255 scope global secondary p2p1
>>    inet6 fe80::a00:27ff:fe36:bfb0/64 scope link
>>       valid_lft forever preferred_lft foreve
>>
>>
>>
>> --
>> Never be afraid to laugh at yourself, after all, you could be missing out on the joke
>> of the century. -- Dame Edna Everage
> Then the documentation [1] is either wrong or did I completely read it wrong?
>
>
> [1] http://docs.fedoraproject.org/en-US/Fedora/16/html/System_Administrators_Guide/s2-networkscripts-interfaces-alias.html

I didn't read the documentation....  :-)

I think that method is how to do it when NetworkManager isn't being used.  What I was
describing was if you were using NetworkManager.

One "downside" if using my method is that "ifconfig" won't show the second IP
address.  But since "Ifconfig" has been depreciated....  :-) :-)

In any case, these configuration won't work when DHCP is desired.

-- 
Never be afraid to laugh at yourself, after all, you could be missing out on the joke
of the century. -- Dame Edna Everage


More information about the users mailing list