LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-10-2010, 12:44 PM   #1
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Two IP addresses using one NIC. Possible?


Hello

Is it possible to configure two IP addresses using one NIC?

I'm implementing a VPN server on network 192.168.1.0, ultimately to be accessed over the Internet and through an ADSL router with port-forwarding to the server. Right now I'd like to test it on the LAN, but with the VPN client and server both on the 192.168.1.0 network, that test would not be be valid.

If I had a spare NIC I could put the server on both the 192.168.1.0 network and, say, a 10.0.0.0 network, configure the client on 10.0.0.0 and test. Not having a spare NIC, I'm wondering if it is possible to configure the server with two IP addresses using one NIC.

Virtualising hosts are able to do something similar when running guests with NICs in bridged mode. Log files show they switch eth0 into promiscuous mode.

In case it matters the server OS is Slackware 13.0.

Best

Charles
 
Old 02-10-2010, 12:51 PM   #2
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
Yes you can: ifconfig <interface> add <address>

see ifconfig(8) for details.
 
1 members found this post helpful.
Old 02-10-2010, 12:52 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Thanks irmin That's helpful

EDIT: is it possible to make the change permanent?

Last edited by catkin; 02-10-2010 at 12:59 PM.
 
Old 02-10-2010, 04:02 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,980

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
Not all nic's support multiple ip addresses. I would guess that most modern one would.


http://www.slackware.com/config/network.php

I think if I were to run a test with VM's I'd setup the vm with local access. VM's tend to have a few options. Bridged, host, local and not connected are normal choices.

Last edited by jefro; 02-10-2010 at 05:06 PM.
 
Old 02-10-2010, 11:51 PM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by jefro View Post
Not all nic's support multiple ip addresses. I would guess that most modern one would.

http://www.slackware.com/config/network.php

I think if I were to run a test with VM's I'd setup the vm with local access. VM's tend to have a few options. Bridged, host, local and not connected are normal choices.
Thanks jefro

For completeness ...

ifconfig eth0 add <address> worked to add another IP address, creating eth0:0. If a different broadcast and/or netmask is required for the new address it cannot be added at the same time (or it changes eth0, rather than eth0:0). The solution is to use two commands:
Code:
ifconfig eth0 add <address>
ifconfig eth0:0 netmask <netmask> broadcast <broadcast>
Regards configuring eth0:0 at boot time, Slackware's network initialisation script (/etc/rc.d/rc.inetd1) is not coded to do it. The purest way to configure eth0:0 at boot time would be to add the commands to /etc/rc.d/rc.local. Alternatively, to configure all the network at the same time, the commands could be added to /etc/rc.d/rc.M after calling rc.inetd1. An alternative is necessary if a network application dependent on eth0:0 is started before rc.local is run.

Whichever solution is chosen, it would be helpful to log to /var/log/messages or to console (maybe using /etc/rc.d/rc.inetd1's technique).

All of which was no help for my local VPN testing! The server started OK according to /var/log/openvpn:
Code:
Thu Feb 11 11:04:55 2010 OpenVPN 2.0.9 i486-slackware-linux [SSL] [LZO] [EPOLL] built on Jun 11 2007
Thu Feb 11 11:04:55 2010 TUN/TAP device tun0 opened
Thu Feb 11 11:04:55 2010 /sbin/ifconfig tun0 10.100.6.1 pointopoint 10.100.6.2 mtu 1500
Thu Feb 11 11:04:55 2010 UDPv4 link local (bound): 10.0.0.41:1194
Thu Feb 11 11:04:55 2010 UDPv4 link remote: [undef]
Thu Feb 11 11:04:55 2010 Initialization Sequence Completed
The client started trying to connect to the server but failed:
Code:
Thu Feb 11 11:05:15 2010 OpenVPN 2.0.9 Win32-MinGW [SSL] [LZO] built on Oct  1 2006
Thu Feb 11 11:05:15 2010 MANAGEMENT: TCP Socket listening on 127.0.0.1:7505
Thu Feb 11 11:05:15 2010 IMPORTANT: OpenVPN's default port number is now 1194, based on an official port number assignment by IANA.  OpenVPN 2.0-beta16 and earlier used 5000 as the default port.
Thu Feb 11 11:05:15 2010 WARNING: No server certificate verification method has been enabled.  See http://openvpn.net/howto.html#mitm for more info.
Thu Feb 11 11:05:15 2010 Control Channel MTU parms [ L:1541 D:138 EF:38 EB:0 ET:0 EL:0 ]
Thu Feb 11 11:05:15 2010 Data Channel MTU parms [ L:1541 D:1450 EF:41 EB:4 ET:0 EL:0 ]
Thu Feb 11 11:05:15 2010 Local Options hash (VER=V4): '3514370b'
Thu Feb 11 11:05:15 2010 Expected Remote Options hash (VER=V4): '239669a8'
Thu Feb 11 11:05:15 2010 UDPv4 link local: [undef]
Thu Feb 11 11:05:15 2010 UDPv4 link remote: 10.0.0.41:1194
Thu Feb 11 11:05:16 2010 write UDPv4: Socket is not connected (WSAENOTCONN) (code=10057)
[above repeated many times until manually terminated]
The client's network configuration looks OK to me ("Ethernet adapter Local Area Connection 2" is waiting for the VPN connection):
Code:
Windows IP Configuration

        Host Name . . . . . . . . . . . . : cw8xp
        Primary Dns Suffix  . . . . . . . :
        Node Type . . . . . . . . . . . . : Unknown
        IP Routing Enabled. . . . . . . . : No
        WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Local Area Connection 2:

        Media State . . . . . . . . . . . : Media disconnected
        Description . . . . . . . . . . . : TAP-Win32 Adapter V8
        Physical Address. . . . . . . . . : 00-FF-EC-E8-A8-D1

Ethernet adapter Local Area Connection:

        Connection-specific DNS Suffix  . :
        Description . . . . . . . . . . . : AMD PCNET Family PCI Ethernet Adapter
        Physical Address. . . . . . . . . : 08-00-27-76-49-76
        Dhcp Enabled. . . . . . . . . . . : No
        IP Address. . . . . . . . . . . . : 10.0.0.48
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 10.0.0.1
        DNS Servers . . . . . . . . . . . : 10.0.0.1
                                            85.10.213.4
Never mind, eh? It would have been nice to prove the VPN system worked locally before introducing the extra complexity of an independent Internet connection and ADSL router port-forwarding.
 
  


Reply

Tags
eth0, ip, multihomed, nic



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
NIC PCI Addresses hybernate20 Linux - Networking 12 08-31-2009 09:49 AM
One NIC, Two IP Addresses Ramonvel Slackware 12 08-07-2007 10:02 AM
Two or more different ip addresses on one NIC? izvrashenj Linux - Networking 3 03-30-2007 04:56 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

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:38 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration