CentOS Ubuntu Network Configuration

Source: Internet
Author: User

CentOS Network Configuration


Turn on network functions
#vi/etc/sysconfig/network
Important Parameters:
Networking=yes want to have a network
Whether Networking_ipv6=no supports IPV6
Hostname= Host Name

Configuration file for Nic

Related network configuration files and directories:
    /etc/sysconfig/network-scripts/         The directory for the configuration file that holds the NIC
    
Take/etc/sysconfig/network-scripts/ifcfg-eth0 as an example:
Configuration file for network card eth0, important parameters:
        DEVICE=eth0                          Network card code
        bootproto= dhcp                     using DHCP
         HWADDR=08:00:27:c7:fe:ac      network card number (MAC)
         UUID=                              Globally unique identifier, virtual machine general hwaddr= ...

This does not exist, only the UUID entry identifies the NIC, which can be manually

Add Hwaddr=mac and then delete the UUID entries and restart to use your Mac

                                             identity card

        ipaddr= 192.168.100.127             Static IP address (cannot exist with BOOTPROTO=DHCP)
        NETMASK=255.255.255.0              Subnet Mask

        ONBOOT=    yes                      Start this interface by default

         gateway= Gateway ip                      If there are multiple network cards, there is only one configuration file for the NIC

There can be gateway, which means that the system gateway can have only one

Peerdns=no does not allow DNS servers in/etc/resolv.conf that are set locally

Modify the settings for the DHCP server, it is best to remove this, otherwise you may

It's not going to be a net!

nm_controlled= Additional network management software (cancellation is recommended)


Here's a/etc/resolv.conf. This configuration file:
Format
NameServer DNS Server IP
This file configures our host to use the DNS server, can be manually modified, but if the use of DHCP to obtain an IP address, then the nameserver of this file will be modified to the DHCP server preset DNS, So if you want to use your own custom DNS but also DHCP to obtain IP, then the corresponding/ETC/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-ETHX NIC configuration file plus a line peerdns=no can


VBox virtual machine Add a virtual network card, you will find that the use of the Ifconfig command did not find the newly added network card, and there is no corresponding configuration file/etc/sysconfig/network-scripts/. Check to see if your network card is recognized by the system:

#cat/etc/udev/rules.d/70-persistent-net.rules

The virtual network card that can be added here is recognized, but there is no configuration file, so just add a corresponding name of the IFCFG-ETHX profile and then start the network card or restart the net. You can copy a copy of the Ifcfg-eth0 configuration file for the newly added ethx ifcfg-ethx file, and then modify the parameters inside. And then
#ifdown EHTX

#ifdup EHTX

or restart the network.
#/etc/init.d/network restart


Ubuntu Network Configuration

Ubuntu is connected with two NICs, Eth0 and eth1. eth0 on the IP for automatic acquisition, eth1 on the manual set

Open Ubuntu Network adapter profile/etc/network/interfaces, modify the following

#开机自动挂载lo eth0 eht1 NIC

Auto Lo eth0 eth1

Iface Lo inet Loopback

Iface eth0 inet DHCP

Iface eth1 inet Static
Address 192.168.0.50
Netmask 255.255.255.0
Network 192.168.0.0
Broadcast 192.168.0.255
Gateway 192.168.0.1

Write the save, then open the terminal run the following command, restart the network card:
$/etc/init.d/networking restart

You can also restart the NIC for the new configuration to take effect without affecting other network interfaces:
$ sudo ifdown eth1
$ sudo ifup eth1

You can also get the address by typing the following command directly below the command line
$sudo dhclient eth0

CentOS Ubuntu Network Configuration

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.