Network configurations of centoos, suse, and ubuntu versions
Centos Network Configuration
Environment:
System hardware: vmware vsphere (CPU: 2*4 cores, 2 GB memory)
System Version: Centos-6.5-x86_64
Router Gateway: 192.168.1.1
Steps:
1. view the network MAC address
[Root @ centos ~] # Cat/etc/udev/rules. d/70-persistent-net.rules
The following information is displayed:
# PCI device 0x15ad: 0x07b0 (vmxnet3)
SUBSYSTEM = "net", ACTION = "add", DRIVERS = "? * ", ATTR {address} =" 00: 50: 56: 94: 04: 3c ", ATTR {type} =" 1 ", KERNEL = "eth *", NAME = "eth0"
# PCI device 0x15ad: 0x07b0 (vmxnet3)
SUBSYSTEM = "net", ACTION = "add", DRIVERS = "? * ", ATTR {address} =" 00: 50: 56: 94: 53: 24 ", ATTR {type} =" 1 ", KERNEL = "eth *", NAME = "eth1"
Eth0: corresponds to the first Nic, and eth1: The second Nic. Currently, eth0 is used to connect to the vro, and eth1 is retained (the server is generally used to connect to other hosts)
2. Modify host name
[Root @ centos ~] # Vim/etc/sysconfig/network
Open the file, modify the following content, and save
NETWORKING = yes # use the network
HOSTNAME = centos # Set Host Name
3. Modify the NIC
[Root @ centos ~] # Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Open the file, modify the following content, and save
DEVICE = eth0 # corresponds to the first Nic
TYPE = Ethernet
ONBOOT = yes # run at startup
NM_CONTROLLED = yes
BOOTPROTO = static # use a static IP address instead of an IP address allocated by DHCP
DEFROUTE = yes
20174_failure_fatal = yes
IPV6INIT = no
NAME = "System eth0" # NAME
HWADDR = 00: 50: 56: 94: 04: 3C # It must correspond to the MAC address of etho (/etc/udev/rules. d/70-persistent-net.rules)
PEERDNS = yes
PEERROUTES = yes
IPADDR = 192.168.1.40 # specify the local IP Address
NETMASK = 255.255.255.0 # specify the subnet mask
GATEWAY = 192.168.1.1 # specify the GATEWAY
4. Modify DNS
[Root @ centos ~] # Vim/etc/resolv. conf
Open the file, modify the following content, and save
Nameserver 8.8.8.8 # GOOGLE's DNS Server
Nameserver 61.144.56.100 # specify the nearest DNS server in the current city (different cities, online search)
Nameserver 192.168.1.1 # specify the DNS server specified on the router
5. Restart Network Configuration
[Root @ centos ~] # Service network restart
6. Restart
[Root @ centos ~] # Shutdown-r now
7. view the current IP settings
[Root @ centos ~] # Ifconfig
8. Test whether to connect to the Internet
[Root @ centos ~] # Ping www.163.com
Ubuntu Network Configuration
I. configuration is divided into three categories: configuration through the configuration file, command configuration, and graphical network connection menu configuration.
Unlimited labs such as dial-up wireless are not involved.
Main file:/etc/network/interfaces. Here are some configurations of IP address, gateway, mask, etc;/etc/resolv. conf this file stores DNS information
Main Command: restart the network with sudo/etc/init. d/networking restart to invalidate the configuration file; add default gw in sudo route <IP address> to set the gateway.
Ii. configuration method
1. Configure through commands
If you only want to temporarily modify the IP address, you can choose this method. After the network is restarted, it will be lost.
1) sudo ifconfig eth0 <IP address> netmask <subnet mask> up
Eth0 is the network card. The last "up" indicates that the NIC is enabled and can be left empty.
2) sudo route add default gw <gateway IP address>
Set Gateway
3) set DNS, which must be modified in the configuration file.
4) configure the Host Name
Command: sudo/bin/hostname <Host Name>
However, when the system starts, the host name is read from/etc/hostname.
2. Configure through the configuration file
1) configure the IP Gateway: add it to sudo gedit/etc/network/interfaces
Dhcp:
auto loiface lo inet loopbackauto eth0iface eth0 inet dhcp
Static IP:
Auto loiface lo inet loopback # The above is the loop # The eth0 configuration of the NIC auto eth0 # staic static IPiface eth0 inet staticaddress contains 255.255.255.255.0gateway 192.168.1.1 # network 192.168.3.0 # broadcast 192.168.3.255 # broadcast number, this can be calculated by other information, so you do not need to set
The second IP address (virtual IP address) can also be configured here)
auto eth0:1iface eth0:1 inet staticaddress 192.168.1.60netmask 255.255.255.0#network x.x.x.x#broadcast x.x.x.xgateway x.x.x.x
2) Configure DNS: sudo gedit/etc/resolv. conf
nameserver 202.107.117.11
3) Host Name: Enter the host name in sudo gedit/etc/hostname. By default, a host name is provided, so this is not required.
4) restart the network: sudo/etc/init. d/networking restart
You can also restart the NIC:
sudo ifconfig eth0 down sudo ifconfig eth0 up
Restarting the NIC does not affect other NICs. We recommend that you restart the NIC.
3. graphical network connection menu Configuration
This is also called network manager in system-preferences. You can use the network management Applet in the upper right corner to enable its configuration.
This is a problem: it shares the configuration file with the second method, which may lead to various conflicts.
As a result, both methods are configured, sudo/etc/init. d/networking restart enables the second method of configuration, and click auto eth0 in the network management applet on the desktop panel to enable the third method.
Suse Network Configuration
For how to correctly configure the SUSE network, here are the steps for configuring the SUSE network. You can learn about SUSE network configuration more concisely and quickly. Correct SUSE network configuration.
1. Run yast to start the NIC.
2. Enter/etc/sysconfig/netwrok/and find the corresponding network file. It is generally an ifcfg-eth * file.
3. vi ifcfg-eth *
4. configuration of typical ifcfg-eth0
BOOTPROTO = 'static'
BROADCAST = '2. BROADCAST 255.255'
IPADDR = '2. 2.2.123'
MTU =''
NETMASK = '2014. 0.0.0'
NETWORK = '2. 0.0.0'
REMOTE_IPADDR =''
STARTMODE = 'onboot'
_ Nm_name = 'static-0'
5./etc/init. d/network start the network
6. Temporary ip Address: ifconfig eth0 2.2.2.123 up
7. Terminate and start a NIC: ifdown eth0, ifup eth0
8. ifconfig-a displays ip configuration.
This completes the SUSE network configuration.