LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 08-06-2007, 06:38 PM   #1
Ramonvel
LQ Newbie
 
Registered: Aug 2007
Posts: 19

Rep: Reputation: 0
One NIC, Two IP Addresses


Hi,

I need to assign two IP addresses to one NIC card. I found out about how to do it on Fedora/ RedHat, CentOS, but no luck with slackware.

All help is greatly appreciated, Thanks
 
Old 08-06-2007, 07:40 PM   #2
raska
Member
 
Registered: Aug 2004
Location: Aguascalientes, AGS. Mexico.
Distribution: Slackware 13.0 kernel 2.6.29.6
Posts: 816

Rep: Reputation: 30
Hi, welcome to Slackware, the exciting distro where you do everything by hand

On this case for a secondary IP address for the same NIC it's just as easy as setting up another network interface, but with a little twist.

With ifconfig refer to the secondary IP with a :N suffix, there the N is some sort of numerical index, I'm not sure if there is a limit for more IP's. Here is an example that I have just tried on my machine

Code:
get yourself some root powers
:~$ su -
Password:

let's look at the device current setup...
root@zee:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:15:F2:18:B3:66
          inet addr:192.168.3.1  Bcast:192.168.3.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:538151 errors:0 dropped:0 overruns:0 frame:0
          TX packets:516574 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:348025281 (331.9 MiB)  TX bytes:254141627 (242.3 MiB)
          Interrupt:18 Base address:0x4000

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:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:100 (100.0 b)  TX bytes:100 (100.0 b)

this is the cool line
root@zee:~# ifconfig eth0:1 192.168.20.1 netmask 255.255.255.0 up

check again
root@zee:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:15:F2:18:B3:66
          inet addr:192.168.3.1  Bcast:192.168.3.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:539041 errors:0 dropped:0 overruns:0 frame:0
          TX packets:517361 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:348511684 (332.3 MiB)  TX bytes:254587368 (242.7 MiB)
          Interrupt:18 Base address:0x4000

eth0:1    Link encap:Ethernet  HWaddr 00:15:F2:18:B3:66
          inet addr:192.168.20.1  Bcast:192.168.20.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0x4000

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:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:100 (100.0 b)  TX bytes:100 (100.0 b)

now ... what if I don't want it anymore...
root@zee:~# ifconfig eth0:1 down

it's gone, just as expected :D 
root@zee:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:15:F2:18:B3:66
          inet addr:192.168.3.1  Bcast:192.168.3.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:548612 errors:0 dropped:0 overruns:0 frame:0
          TX packets:526503 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:354777456 (338.3 MiB)  TX bytes:259399416 (247.3 MiB)
          Interrupt:18 Base address:0x4000

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:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:100 (100.0 b)  TX bytes:100 (100.0 b)
I hope this serves you as well.

Godspeed.

Last edited by raska; 08-06-2007 at 07:45 PM.
 
Old 08-06-2007, 08:28 PM   #3
Murkhadh
LQ Newbie
 
Registered: Feb 2007
Posts: 22

Rep: Reputation: 15
Wireless

Would this same technique work for using the same wireless NIC on more than one network/SSID?
 
Old 08-06-2007, 08:28 PM   #4
Ramonvel
LQ Newbie
 
Registered: Aug 2007
Posts: 19

Original Poster
Rep: Reputation: 0
One NIC, two IP

Awesome!!!

Thanks a million Raska. I did it and I was able to ping to it.

Again, Thanks! )

Ray
 
Old 08-07-2007, 06:20 AM   #5
MS3FGX
Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
Quote:
Would this same technique work for using the same wireless NIC on more than one network/SSID?
No, that is a limitation of the wireless hardware.

Last edited by MS3FGX; 08-07-2007 at 08:42 AM.
 
Old 08-07-2007, 07:37 AM   #6
Murkhadh
LQ Newbie
 
Registered: Feb 2007
Posts: 22

Rep: Reputation: 15
Wireless

MS3FGX, that doesn't quite make sense, if its a hardware limitation, why it possible to do that in windows using the same hardware?
 
Old 08-07-2007, 07:42 AM   #7
Mark Havel
Member
 
Registered: May 2004
Location: Lyon, France
Distribution: Slackware
Posts: 85

Rep: Reputation: 15
Quote:
Originally Posted by Murkhadh
MS3FGX, that doesn't quite make sense, if its a hardware limitation, why it possible to do that in windows using the same hardware?
Probably because this is a proprietary feature of the driver or the utilities joined with the drivers. Anyway, I think this must be somewhat crappy for the bandwidth of your NIC is still the same and then, you divide an already low bandwidth by the number of wireless networks you connect.
 
Old 08-07-2007, 08:08 AM   #8
MS3FGX
Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
Quote:
if its a hardware limitation, why it possible to do that in windows using the same hardware?
Windows does not natively allow you to connect to multiple SSIDs at the same time. You can specify multiple SSIDs for it to chose from, and it will intelligently (I use the term lightly) determine which one to connect to based on various factors, but it cannot connect to them at the same time. This is, as I said earlier, a limitation of the physical hardware design. WiFi hardware was not designed to connect to multiple networks at once, largely because of how difficult that is to do with RF technology. Try and tune your car radio into two different stations at the same time, and you will get the idea.

The only way this is possible under Windows is using VirtualWiFi. This is not part of any mainline Windows release though, and is only a research project from Microsoft Research. It is still experimental software, but the benefit is that you can be "simultaneously" connected to multiple networks at once.

However, if you read their documentation, what is actually happening is that the driver virtualizes multiple interfaces that are configured independently as normal WiFi cards; the driver then rapidly switches between them so the process is transparent to the user. At no time is the card actually authenticated to more than one AP at a time, it just seems that way. If you really wanted to, you could do the same thing with a Bash script, though I don't know how well it would actually work; clearly there is some trickery going on with VirtualWiFi to minimize authentication times, buffer data, etc.

As Mark said, there may be cards that feature this as a proprietary feature (and as such then require proprietary drivers), but I have not personally ever heard of such cards existing, and it would definitely fall outside of the normal WiFi specs. Though on the other hand, this is not in itself an unusual situation; as 128 bit WEP is not part of the original WiFi specifications (due to laws limiting the cryptographic capability of exported devices), and was adopted later by hardware manufacturers independently (which is there is occasionally compatibility issues with 128 bit WEP between different brands of hardware).
 
Old 08-07-2007, 08:19 AM   #9
Murkhadh
LQ Newbie
 
Registered: Feb 2007
Posts: 22

Rep: Reputation: 15
Whoa there

I never said at the same time.

I'm referring to something more like the "preferred Networks" order. Meaning windows goes down a list of "preferred" networks (SSID's) in order till it finds one.

The end goal is to not have to manually enter a SSID when i go from one familiar network to the next (home to work)
 
Old 08-07-2007, 08:24 AM   #10
Mark Havel
Member
 
Registered: May 2004
Location: Lyon, France
Distribution: Slackware
Posts: 85

Rep: Reputation: 15
Aah, then it depends on the utility used to manage the Wifi connections. I think the ones included in KDE mimic the Windows utility so you can store profiles and switch between them at will (or maybe even automatically) but I'm not sure.
 
Old 08-07-2007, 08:44 AM   #11
MS3FGX
Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
Yes, in that case it is simply down to which WiFi manager software you are using. KDE has it's own (it has many, actually), GNOME has theirs, and then there are dozens of others ranging from GTK applications all the way to Bash/Perl scripts.
 
Old 08-07-2007, 10:00 AM   #12
Murkhadh
LQ Newbie
 
Registered: Feb 2007
Posts: 22

Rep: Reputation: 15
ya i was looking for a way to do it from the command line.
 
Old 08-07-2007, 10:02 AM   #13
MS3FGX
Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
iwconfig does not have the capability to store and select between pre-configured networks, unfortunately. You need some middle-man application to do that for you, and then pass the information to iwconfig itself.

There are however applications like that which can do so on the command line. For example, WiFiRadar has a GTK interface but can also be told to automatically connect to the best network from the command line.
 
  


Reply

Tags
ifconfig, ip, secondary


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Two or more different ip addresses on one NIC? izvrashenj Linux - Networking 3 03-30-2007 04:56 PM
Binding multiple IP Addresses to same NIC Harlin Linux - Networking 4 10-26-2005 05:10 AM
multiple ip addresses on 1 nic? houler Linux - Networking 4 04-26-2005 03:53 PM
1 NIC with 2 IP addresses bucklake Linux - Networking 3 02-20-2004 10:44 AM
Multiple IP addresses on one NIC hrr Linux - Networking 2 03-07-2003 12:04 PM


All times are GMT -5. The time now is 03:47 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration