Configuration of virtual network adapters for Linux networks (Ubuntu 16.04)

Source: Internet
Author: User
Tags nameserver

First introduce the configuration of the virtual network card under Ubuntu (I'm using ubuntu-16.04)

1, first use ifconfig to view the current network card configuration

Ens33     Link encap: Ethernet  Hardware address 02:0c:29:c6:be:c7            INET6 address: fe80::20c:29ef:fec6:bec7/64 Scope:link          up Broadcast RUNNING multicast  mtu:1500  hop count: 1          receive packet: 215 Error: 0 Discard: 0 Overload: 0 Number of frames: 0          Send packet: 256 error: 0 Discard: 0 Overload: 0 Carrier: 0          collisions: 0 Send Queue Length: +           Bytes Received: 25858 (25.8 kb)  send bytes: 27711 (27.7 kb) lo        Link encap: Local loopback            inet address: 127.0.0.1  Mask: 255.0.0.0          Inet6 Address::: 1/128 scope:host up          LOOPBACK RUNNING  mtu:65536  metric: 1 Receive packet          : 165 error : 0 Discard: 0 Overload: 0 Number of frames: 0          Send packet: 165 error: 0 Discard: 0 Overload: 0 Carrier: 0          collisions: 0 Send Queue Length: 1           Receive bytes: 12225 (12.2 kb)  Send bytes: 12225 (12.2 KB)

The information printed above is typically not set before it is shown above.

2. Check the current network card configuration, open the configuration file/etc/network/interfaces

sudo vim/etc/network/interfaces

You can see the network card configuration with only one loopback test

Auto Loiface lo inet loopback

3, choose to add our own network card configuration, the first network card (ENS33) configuration must be outside the network, if you configure the intranet, it will cause your system can not Sisu network.

Addresses, masks, and gateways are configured according to their actual network. My network IP here is 172.16.2.xxx network segment.

Auto Ens33iface ens33 inet static #设置静态IP, dynamic is to modify the static to DHCP, if set to dynamic IP cannot set the virtual network card address 172.16.2.95 # If the dynamic IP is not configured below. Netmask 255.255.0.0gateway 172.16.254.254

4, next configure the Virtual network card (ens33:1)

The same intranet IP according to the actual situation, I here the intranet IP is 192.168.8.xxx network segment.

Auto Ens33:1iface ens33:1 inet staticaddress 192.168.8.95netmask 255.255.255.0gateway 192.168.8.1

This way you can access both the intranet and the Internet.

Suppose you add an intranet virtual network card with more than one other network segment.

Auto Ens33:2iface ens33:2 inet staticaddress 192.168.88.95netmask 255.255.255.0gateway 192.168.88.1

And so on, can increase many different network segments of the intranet network card, can each other access.

5. Configure the default gateway

Open/etc/resolv.conf

sudo vim/etc/resolv.conf

To add a gateway to the configuration file for the network segment configured above, we have three network segments configured above, then add the following information to our configuration file

NameServer 172.16.254.254nameserver 192.168.8.1nameserver 192.168.88.1

This is possible in previous versions, but in the new version you will also add the above content to another configuration file.

Open/etc/resolvconf/resolv.conf.d/base

sudo vim/etc/resolvconf/resolv.conf.d/base

Pass-through increases above three default gateways

NameServer 172.16.254.254nameserver 192.168.8.1nameserver 192.168.88.1

6. Restart the computer reboot

  After modifying these, only restart the computer to take effect, with the command to restart the network card (sudo/etc/init.d/networking restart) is not useful. The reasons are not yet clear.

Restart the computer and then use Ifconfig view, there are multiple network card configuration, and can use, non-conflict.

Configuration of virtual network adapters for Linux networks (Ubuntu 16.04)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.