D
D
dlinyj2012-12-11 15:12:01
Network administration
dlinyj, 2012-12-11 15:12:01

Creating a virtual interface

I want something weird.

There is a certain device (router) which runs under Linux.

The piece of iron can access the Internet via several interfaces (wifi, japares), plus it has two network interfaces. A switch hangs on one of them, to which the subnet is already connected (let's say 192.168. 1. *, which will receive the Internet. Also, another router can be connected to the same switch, which can also distribute the Internet. And it should already be another subnet (for example, 192.168.0. */24) .The task is to hang one or two virtual ones on the same physical interface, with different IPs.This is done for the convenience of routing.There were attempts to implement this through vconfig xgu.ru/wiki /man


:vconfig, however, was not successful. While I'm testing on my computer running Ubuntu 12.04

If you need any tricky console utilities, list them, build them, try them.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
astrobeglec, 2012-12-11
@astrobeglec

The easiest and most effective way: Open the /etc/network/interfaces file with a text editor as superuser, like this

sudo gedit /etc/network/interfaces

And edit it to look like this:
auto eth0
iface eth0 inet static
  address 192.168.1.5
  netmask 255.255.255.0
  network 192.168.1.0
  broadcast 192.168.1.255
  gateway 192.168.1.1
  dns-nameservers 8.8.8.8 192.168.1.1

auto eth0:1
iface eth0:1 inet static
  address 192.168.0.5
  netmask 255.255.255.0
  network 192.168.1.0
  broadcast 192.168.1.255
  gateway 192.168.0.1
  hwaddress ether 00269ebba619
  dns-nameservers 8.8.8.8 192.168.1.1


where:
auto eth0 - automatic lifting of the network interface
iface eth0 inet static - a static address is used
(if the address issues dhcp, then you write iface eth0 inet static)
address 192.168.1.5 - IP address of interface 1
netmask 255.255.255.0 - network mask
network 192.168.1.0 and broadcast 192.168.1.255 - this can be omitted, but it will not be superfluous either.
gateway 192.168.1.1 - gateway (IP address of the device to access the Internet)
dns-nameservers 8.8.8.8 192.168.1.1 - DNS server
auto eth0:1 - the second network interface on this device and then by analogy.

S
SleepingLion, 2012-12-11
@SleepingLion

You just need to set up an alias - hang two IPs on one interface. It is configured differently for different distributions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question