Is it possible to create virtual ethernets in Linux?

344705 pts.
Tags:
Ethernet
Linux
We're currently doing a project based on implementing a protocol that basically talks between two different computers using an ethernet. Instead of having two physical computers, we want to create two virtual ethernet interfaces and have them only talk to each other (one would bind to the other). Is this actually possible?

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi ,
I would suggest  you to go for IP aliasing , in which you can assign 2 or more IP address to same
Ethernet .It will resolve your problem . To can test you protocol  working from this.

Please find step fot Ip aliasing .

Step 1 : Here I have an interface called “ifcfg-eth0“, the default interface for the Ethernet device.

# cd /etc/sysconfig/network-scripts/
# ls -l

Let’s assume that we want to create 1 additional virtual interfaces to
 bind IP addresses (172.16.105.4, 172.16.105.5 ) to the NIC.

his is how we moving forward to setup three aliases to bind the following IP addresses.

Adapter            IP Address                Type
————————————————-
eth0              172.16.105.4            Primary
eth0:0            172.16.105.5            Alias 1

Where “:X” is the device (interface) number to create the aliases for interface eth0.

Step 2 :
Open a file “ifcfg-eth0” and view the contents.
# vi ifcfg-eth0

DEVICE=”eth0″
BOOTPROTO=static
ONBOOT=yes
TYPE=”Ethernet”
IPADDR=172.16.105.5
NETMASK=255.255.255.192
GATEWAY=172.16.105.3
HWADDR=*******************

# vi ifcfg-eth0:0
DEVICE=”eth0:0″
BOOTPROTO=static
ONBOOT=yes
TYPE=”Ethernet”
IPADDR=172.16.105.5
NETMASK=255.255.255.192
GATEWAY=172.16.105.3
HWADDR=*********same-as-eth0**********

Same it  . Now u  have to  restart Network
 
Step 2:
# /etc/init.d/network restart

[root@hostanme]# ifconfig
eth0      Link encap:Ethernet  HWaddr ********************
          inet addr:172.16.105.4  Bcast:172.16.105.63  Mask:255.255.255.192
          inet6 addr:************ Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:237 errors:0 dropped:0 overruns:0 frame:0
          TX packets:198 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:25429 (24.8 KiB)  TX bytes:26910 (26.2 KiB)
          Interrupt:18 Base address:0×2000

eth0:0    Link encap:Ethernet  HWaddr *****************
          inet addr:172.16.105.5  Bcast:172.16.105.63  Mask:255.255.255.192
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:18 Base address:0×2000

Step 3:
Ping each of them from different machine. If everything setup correctly,
you will get a ping response from each of them.

ping 172.16.105.4
ping 172.16.105.5
 
Here .Both 2 IP have to be  belong to same  .
Hope this will help u . I welcome if u have any other Query .U can do Protocol testing with these 2 different .

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following