Basic configuration method of network under CentOS

Source: Internet
Author: User

We have successfully installed our CentOS system in the previous article, but we may find that we do not have a web on the CentOS installation, so this Chapter We say how to configure CentOS to connect the extranet and local area network.

Let us first meet some of the Linux network configuration files, we often use several network configuration files are

/etc/udev/rules.d/70-persistent-net.rules You can see the MAC address of the machine in this configuration file (you can root The number of network cards is shown in this configuration file)

/etc/resolv.conf configuration modifies DNS (sometimes you can configure DNS by modifying the Ifcfg-eth0 file, and after this file is restarted, the Dynamic DNS Generation)

/etc/sysconfig/network Host name configuration file

/etc/sysconfig/iptables Firewall configuration file

/etc/sysconfig/network-scripts/ifcfg-eth0 Network card configuration file (there may be multiple network cards, there are multiple network adapters with file Ifcfg-ethx)

Network Configuration commands

Service Network Restart Restart Network configuration command

Restart PC command

Shutdown-h now shutdown command

The following is a detailed description of the network configuration process:

The first step is to configure the NIC configuration

Using the command Vi/etc/sysconfig/network-scripts/ifcfg-eth0

Edit the contents of the modified file as follows: (#号后面为注释)

Device=eth0 #对应第一张网卡 (general original file without modification)

hwaddr=74:27:ea:44:df:5e #对应网卡MAC地址 (general original file without modification)

Type=ethernet # (general original file without modification)

UUID=354C1215-D163-4181-9E26-1C5DCCC91C53 # (general original file without modification)

Onboot=yes #是否启动时运行

Nm_controlled=yes # (general original file without modification)

Bootproto=static #使用静态IP instead of assigning IP by DHCP

ipaddr=192.168.4.231 #指定本机IP地址

netmask=255.255.255.0 #指定子网掩码

gateway=192.168.4.1 #指定网关

dns1=8.8.8.8 #指定DNS

The second step is to modify the external NIC profile and restart the network service (automatically generate NameServer 8.8.8.8 in resolv.conf after reboot)

Service Network restart

Test if the network is connected after restarting the third step

Ping www.baidu.com

Fourth step if you want to develop some service ports, you can modify the firewall

Vi/etc/sysconfig/iptables

#在文件中添加这段代码 (? Replace with the port number you want to open)

-A input-m state--state new-m tcp-p TCP--dport? -j ACCEPT

Fifth Step Restart Firewall

Service Iptables Restart

This is the basic network configuration after installing CentOS.

Basic configuration method of network under CentOS

Related Article

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.