LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Slackware 10.2 IP aliasing issue (https://www.linuxquestions.org/questions/linux-networking-3/slackware-10-2-ip-aliasing-issue-487861/)

joe1138 09-28-2006 10:18 PM

Slackware 10.2 IP aliasing issue
 
I've done a ton of Google searches, seems like just about as many searches here and other linux forums and I don't seem to be really getting anywhere trying to make a reboot persistent IP alias for eth0:1. I've found what appears should be doing the job. (/etc/rc.d/rc.inet1 and /etc/rc.d/rc.inet1.conf)

I've edited the rc.inet1.conf:

Code:

# Config information for eth0:
IPADDR[0]="192.168.0.151"
NETMASK[0]="255.255.255.0"
USE_DHCP[0]=""
DHCP_HOSTNAME[0]=""

# Config information for eth1:
IFNAME[1]="eth0:1"
IPADDR[1]="192.168.0.152"
NETMASK[1]="255.255.255.0"
USE_DHCP[1]=""
DHCP_HOSTNAME[1]=""

And when I do a reboot ifconfig nets me:

Code:

eth0      Link encap:Ethernet  HWaddr 00:03:47:1B:D9:36
          inet addr:192.168.0.151  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:18178 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15277 errors:0 dropped:0 overruns:0 carrier:0
          collisions:7 txqueuelen:1000
          RX bytes:19695130 (18.7 Mb)  TX bytes:3569393 (3.4 Mb)
          Interrupt:11 Base address:0x6000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:10 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:772 (772.0 b)  TX bytes:772 (772.0 b)

As root, at the console, if I give the command, /etc/rc.d/rc.inet1 restart, I get:

Code:

SIOCSIFFLAGS:  Cannot assign requested address
and no eth0:1.

Yet from a shell prompt from within KDE X-Windows it assigns eth0:1 just fine. At the console if I run the commands, /etc/rc.d/rc.inet1 stop and /etc/rc.d/rc.inet1 start, it also correctly assigns eth0:1.

Code:

eth0      Link encap:Ethernet  HWaddr 00:03:47:1B:D9:36
          inet addr:192.168.0.151  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:276 (276.0 b)  TX bytes:0 (0.0 b)
          Interrupt:11 Base address:0x6000

eth0:1    Link encap:Ethernet  HWaddr 00:03:47:1B:D9:36
          inet addr:192.168.0.152  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:11 Base address:0x6000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

At this point I'm way beyond stumped. Does anyone have any ideas what's going on?

Wintceas 09-30-2006 07:51 AM

rc.local
 
Why don't you put the command to configure the alias in rc.local?

/sbin/ifconfig eth0:1 192.168.0.152 netmask 255.255.255.0 up

Another question. What's the use of two interfaces with both addresses in the same network?

joe1138 09-30-2006 11:39 AM

Quote:

Originally Posted by Wintceas
Why don't you put the command to configure the alias in rc.local?

Mostly because I consider that a kluge way of doing it, I know there's a better way.

Quote:

Originally Posted by Wintceas
Another question. What's the use of two interfaces with both addresses in the same network?

I'm going to be running a caching only DNS server on my local network and I want it to respond to a different IP address. And more importantly so I know how it's done. :)

PDock 09-30-2006 06:57 PM

Have you looked at rc.inet1? Restart is simply stop start. Chances are everything isn't taken down before start is trying to bring it back up.

As root edit rc.inet1 and within the restart option between stop start; add as a new line without " "sleep 4".

joe1138 10-01-2006 10:01 AM

Thanks PDock, that helped. Now all I have left is the question I initially started with, how to get an IP alias for a single NIC that's persistent across reboots. So far that's only been achievable by adding the ifconfig command into the rc.local file.

PDock 10-02-2006 06:41 PM

Don't think it will work but........
Looks like the rc.inet1 script adds the array number as a suffix to the IFNAME[x]
so try changing in rc.inet1.conf
IFNAME[1] = "eth0:"

also
DEBUG_ETH_UP="yes"

good luck no warranties offered

joe1138 10-03-2006 12:55 AM

You're right, it didn't work but it was well worth a shot.

iri 11-09-2006 02:37 AM

hi there
i'm searching exactly for the same thing :) (assign 2 ip address at boot time to only one eth whitout ifconfig)
i've figure it out that the things you said in the first post are working quite well, and thanks for that :)
but the problem we have, is that /etc/rc.d/rc.inet1 doesn't know how to bring up eth0:1 first and then assign the ip, i think that the first time tries to assing the ip, and then bring eth0:1 up that's why we have that error "SIOCSIFFLAGS: Cannot assign requested address" because i think it's the same error you get when you try to assign with rc.inet1 an ip to eth3 for example that is not up, and also that's why when you restart inet1 after boot, and eth0:1 is up,it assign correctly whitout any errors.
so the problem is with rc.inet1 and we have to find it where, but i don't want to mess it up :) because i'm some kind a rookie :) so i ask somebody else to be kind to look for this problem :)

my configs are:
Code:

# Config information for eth0:
IPADDR[0]="89.39.XXX.XXX"
NETMASK[0]="255.255.255.0"
USE_DHCP[0]=""
DHCP_HOSTNAME[0]=""

# Config information for eth1:
IFNAME[1]="eth0:1"
IPADDR[1]="192.168.100.100"
NETMASK[1]="255.255.0.0"
USE_DHCP[1]=""
DHCP_HOSTNAME[1]=""

p.s. i've put in rc.local
Code:

/etc/rc.d/rc.inet1 restart
and it works, but also it is not the correct way i want it :)

Wintceas 11-09-2006 05:30 AM

IP Aliasing
 
Quote:

Originally Posted by iri

...

p.s. i've put in rc.local
Code:

/etc/rc.d/rc.inet1 restart
and it works, but also it is not the correct way i want it :)


You can't put that command in rc.local. Aliasing won't work from rc.inet1 and you'll run rc.inet1 again to no avail. The only way I know aliasing works is putting the proper command in rc.local, e.g., "/sbin/ifconfig eth0:1 192.168.100.100 netmask 255.255.0.0 up". It works, because rc.local runs after rc.inet1 have configured the real network interface. Good luck!

SlackDaemon 11-09-2006 05:46 AM

Quote:

Originally Posted by joe1138
Mostly because I consider that a kluge way of doing it, I know there's a better way.

Actually the slackware 10.2 scripts are using ifconfig to bring up the interfaces in the background so you end up using the rc.local method anyway. Check out the code in /etc/rc.d/rc.inet1 script and search for ifconfig.

If there are other methods, they are just sugarcoated ways of doing the same thing. I believe future versions will use iproute2 to bring up the interfaces though.

iri 11-09-2006 07:41 AM

you can put anything in rc.local, i'm just restarting rc.inet1 just after the boot, what's wrong in that? rc.inet1 starts normally, rc.local follows and then point the rc.inet1 restart.. what's so wrong in that? :)

SlackDaemon 11-10-2006 10:17 PM

Quote:

Originally Posted by iri
you can put anything in rc.local, i'm just restarting rc.inet1 just after the boot, what's wrong in that? rc.inet1 starts normally, rc.local follows and then point the rc.inet1 restart.. what's so wrong in that? :)


There's nothing wrong with using rc.local. My point was that even if you don't use rc.local, you'll end up using the same code to activate the interface anyway (i.e. with ifconfig)

saf 11-21-2006 12:57 PM

It should work in Slackware 11.0.
From the changelog:

"The network setup script /etc/rc.d/rc.inet1 has been extensively
rewritten (...) One that didn't get listed yet that I'll mention here is support for IP aliasing. This sort of thing should work now for setting static IP aliases: IFNAME[2]="eth0:1""

Danny E. 01-01-2007 11:33 AM

Small addition
 
Quote:

Originally Posted by saf
It should work in Slackware 11.0.
From the changelog:

"The network setup script /etc/rc.d/rc.inet1 has been extensively
rewritten (...) One that didn't get listed yet that I'll mention here is support for IP aliasing. This sort of thing should work now for setting static IP aliases: IFNAME[2]="eth0:1""

I found that the IFNAME still didn't work _unless_ i added IFNAME[0]="eth0" probably has something to do with the 0 instance of the array missing?

Regards, Danny.


All times are GMT -5. The time now is 11:09 PM.