ifcfg-ethX voodoo for a second IP on the same interface
Tommy Pham
tommyhp2 at gmail.com
Sat Apr 21 05:30:11 UTC 2012
On Fri, Apr 20, 2012 at 10:05 PM, Ed Greshko <Ed.Greshko at greshko.com> wrote:
> 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
> --
You're right about the doc and NetworkManager... I had to set it to no
and bring down the service to make it work... But then I'm using F17
beta so maybe NM is broken???
[root at fedora network-scripts]# ls ifcfg-p14*
ifcfg-p14p1 ifcfg-p14p1:1
[root at fedora network-scripts]# cat ifcfg-p14*
UUID="d55f8a84-7d34-48a7-9183-de122db1d244"
NM_CONTROLLED="no"
HWADDR=**:**:**:**:**:**
BOOTPROTO="dhcp"
DEVICE="p14p1"
ONBOOT="yes"
#UUID="d55f8a84-7d34-48a7-9183-de122db1d244"
NM_CONTROLLED="no"
BOOTPROTO="none"
DEVICE="p14p1:1"
ONBOOT="yes"
USERCTL=yes
#TYPE=Ethernet
IPADDR=192.168.0.11
NETMASK=255.255.255.0
#PREFIX=24
#DEFROUTE=yes
IPV4_FAILURE_FATAL=no
#IPV6INIT=no
NAME="System p14p1:1"
UUID=3b279e0d-a2fe-82a3-d15e-6b6fa922d797
p14p1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.241 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::52e5:49ff:fe4e:e55a prefixlen 64 scopeid 0x20<link>
ether **:**:**:**:**:** txqueuelen 1000 (Ethernet)
RX packets 684 bytes 145345 (141.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 703 bytes 88987 (86.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 52 base 0x2000
p14p1:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.11 netmask 255.255.255.0 broadcast 192.168.0.255
ether **:**:**:**:**:** txqueuelen 1000 (Ethernet)
device interrupt 52 base 0x2000
More information about the users
mailing list