Linux network-related configuration files

Source: Internet
Author: User
Tags aliases domain name server nameserver

Linux Network-related profiles Linux systems generally fall into two main categories:1, Redhat series: Redhat, Centos, fedora, etc.;2, Debian series: Debian, Ubuntu and so on. In Linux systems, TCPIP network is configured through a number of text files, you need to configure these files to network, the following for the Linux two major types of systems in the basic tcp/IP network configuration file to do the learning summary. The first type of Debian Ubuntu system for example Ubuntu System network configuration file has interfaces,resolv.conf and so on. One, network interface configuration file:/etc/network/Interfaces1, the contents are as follows: # The loopback networkInterfaceAuto lo# network card boot automatically mount Iface lo inet loopbackauto eth0# network card boot automatically mount, connect network iface eth0 inetStatic#static表示使用固定ip, DHCP represents the use of dynamic IPAddress10.1.101.227#设置ip地址netmask255.255.255.0#设置子网掩码gateway10.1.101.254#设置网关dns-nameservers10.1.101.51modified the interfaces with the following command to make the network settings effective:/etc/init.d/Networking Restart #重启网络2, set a second IP address (virtual IP address) to edit the file/etc/network/interfacesauto eth0:1iface eth0:1inetStaticAddress192.168.1.60netmask255.255.255.0Network X.x.x.xbroadcast x.x.x.xgateway x.x.x.x Two, DNS configuration file:/etc/the resolv.conf can first be/etc/Hosts include some host names and the corresponding IP addresses for these host names, which is a simple static query using native computers. To access the DNS server for querying, you need to set/etc/resolv.conf file. This file sets the IP address and DNS domain name of the DNS server, which is the configuration file used by the domain name resolver. (Domain name resolver: resolver, a library that resolves IP addresses based on host name) domainname domain Search domainname.com #表示提供了一个不包括完全域名的主机时, Add the domainname.com suffix nameserver x.x.x.x# set the preferred DNS after the host, resolve the domain name using the host specified by this address as the name server, in order to find the nameserver appear. NameServer x.x.x.x# set up alternate dnssortlist #对返回的域名进行排序使网络设置生效:/etc/init.d/Networking Restart #重启网络三,/etc/The Hosts file contains a list of known hosts (on the local network). If the system's IP is not dynamically acquired, it can be used. For simple host name resolution (dot notation), before requesting a DNS or NIS network,/etc/hosts.conf will usually tell the parser to check here first. 127.0.0.1localhost localhost.localdomain localhost4 localhost4.localdomain4::1localhost localhost.localdomain localhost6 localhost6.localdomain6 IV,/etc/host.conf When DNS domain name resolution is present in the system and/etc/hosts the host table mechanism, the/etc/host.conf determine the host name interpretation order. Order Hosts,bind #名称解释顺序, order is a keyword that defines the name interpretation first with the native hosts table, and then searches for the Bind name server (DNS) if it cannot be interpreted. Multi on #允许主机有多个IP地址nospoof on #禁止IP地址欺骗五,/etc/servicesinternet Network Service file, convert network service name to port number/agreement. Read by inetd, Telnet, tcpdump, and some other programs. Each row in the file corresponds to a service that consists of 4 fields, separated by a tab or a space, representing the service name, use port, protocol name, and alias. Service Port/Port type alias $ cat/etc/services |Moretcpmux1/TCP # TCP port service Multiplexerecho7/Tcpecho7/Udpdiscard9/TCP SinkNULLDiscard9/UDP SinkNULLSystat One/TCP Usersdaytime -/Tcpdaytime -/Udpnetstat the/TCPQOTD -/TCP Quotemsp -/TCP # Message Send Protocol VI, host name configuration file/bin/hostname uses the command hostname newname to set the new hostname when the system starts, it/etc/hostname to read the host name Vii. network-related scripts and commands/etc/init.d/Networking The Init script at startup of the system, it is responsible for initializing all first-level configured network interfaces when the system starts at a certain level. ifconfig command ifconfig command without any parameters to view the current system network configuration: eth0: Represents the network loopback address of the NIC Lo:linux inside, used to simulate network behavior HWADDR: The hardware address of the NIC, which is the MAC address inet addr: IP address of network card bcast: Broadcast address mask: Subnet mask MTU: Maximum Transmission Unit (Maximum trassmission unit), which identifies the maximum number of packets that can be transmitted for a network interface, which can cause network failure. PX: Network data received up to now TX: Network from boot up to now data transmission situation collisions: Network signal conflict situation the second class Redhat Redhat as an example redhat the network configuration of the system one, modify the IP address1, IP profile Modify the IP address profile of the corresponding network card/etc/sysconfig/network-scripts/ifcfg-<Interface-name>file in Redhat, the configuration file for system network settings is saved inThe/etc/sysconfig/network-scripts directory. Ifcfg-eth0 represents the configuration information for the first NIC, ifcfg-ETH1 represents the configuration information for the second NIC. At startup, the system determines whether a network adapter is started and configured by reading the configuration file. If you want to manually modify the network address or add a new network connection, you can modify the corresponding ifcfg-<Interface-name>or create a new file to implement. Below is/etc/sysconfig/network-scripts/ifcfg-{Interface-the configuration information for name} means device={name} #{name} indicates the name of the network card corresponding to the physical device, Eth0 is the first NIC, two NICs or more eth1,eth*TYPE=Ethernet #网络类型, Ethernet on behalf of Ethernet Onboot=yes/no #系统启动引导时是否激活该网络接口, set to Yes to activate this device nm_controlled=Yesbootproto=none/Static/bootp/dhcp #设置网卡获得ip地址的方式, the possible option is none,Static, BOOTP,DHCP, corresponding to the non-applicable protocol, statically specify the IP address, obtain the IP address through the DHCP protocol, obtain the IP address through the BOOTP protocol ipaddr={Address} #如果设置网卡获得ip地址的方式为静态指定, {addres} represents the IP addresses assigned to the NIC Netmask={Mask} #{mask} represents network mask for Nic={address} #{address} indicates the network address of the NIC (Can not) GATEWAY={address} #{address} default gateway DNS1=10.1.101.51#DNS服务配置BROADCAST={address} #{address} corresponds to the subnet broadcast address, such as 192.168.0.255(can not) macaddr={mac-address} #{mac-Address } indicates that a MAC addresses are specified Userctl=yes/No # Whether to allow non-root users to control the device hwaddr= -: E5: the:d f:b0:8b #对应的网卡物理地址IPV6INIT=No #IPV6IPV6_AUTOCONF=No2, a single NIC binds to 2 IP onlyCreate a/etc/sysconfig/network-scripts directory named ifcfg-eth0:0 file, the sample content is: DEVICE="eth0:0"ipaddr="x.x.x.x"NETMASK="255.255.255.0"If you need to bind more than one IP address, simply add the file name and the eth0:0 in the device in the file. Linux can support a maximum of 255 IP aliases. Second, modify the Gateway gateway configuration file to/etc/sysconfig/the network file gateway configuration can also be/etc/sysconfig/network-scripts/ifcfg-configuration in Eth0. Network is used to specify the networking configuration information on the server, and the file configuration entry has the following meanings:=Yes #表示系统是否使用网络, generally set to Yes, if set to No, the network cannot be used, and many system service programs will fail to start Rorward_ipv4=Yeshostname={hostname} #{hostname} represents the host name of the server, where the hostname and/etc/host name set in the hosts corresponds to Gareway={address} #{address} sets the IP address of the gateway for the native connection, for example, Gateway 10.0.0.2Gatewaydev={device} #{device} indicates the name of the gateway, such as: Eth0network=yes/No #网络是否被配置FORWARD_IPV4=yes/no #是否开启IP转发功能三, modify the Dnsdns configuration file to/etc/the resolv.conf file DNS configuration can also be/etc/sysconfig/network-scripts/ifcfg-configuration in Eth0. The resolv.conf file is used to configure the DNS client, which contains the DNS server address and domain name search configuration. With Ubuntu configuration. Currently, up to three DNS servers are supported. NameServer8.8.8.8#google域名服务器nameserver8.8.8.4#google域名服务器四,/etc/Hosts file at machine startup, before DNS is available for querying, the machine needs to query for some hostname-to-IP address matching. This information is stored in/etc/Hosts file. In the absence of a domain name server, all network programs on the system resolve the IP address corresponding to a host name by querying the file. [[Email protected]-nfs network-scripts]# cat/etc/hosts127.0.0.1localhost localhost.localdomain localhost4 localhost4.localdomain4::1localhost localhost.localdomain localhost6 localhost6.localdomain610.1.101.117Lxy-nfs lxy-nfs.engine.com leftmost is a series of host IP information, in the middle is some column host name. Any subsequent columns are aliases for that host. Five, restart the network configuration method1, #service network restart2, #/etc/init.d/Network Restart3, #ifdown eth0#ifup eth04, #ifconfig eth0 down#ifconfig eth0 up VI, related commands modify IP address1, immediate effect: #ifconfig eth0192.168.0.2Netmask255.255.255.02, restart the system to take effect: Modify/etc/sysconfig/network-scripts/ifcfg-eth0 Modifying the gateway default gateways1, immediate effect #route adddefaultGw192.168.0.2Netmask255.255.255.02, restart the system to take effect: Modify/etc/sysconfig/Network Modify DNS modifications/etc/resolv.conf changes can be effective immediately, start the same effective change host name1, immediate effect hostname newname2, restart the system to take effect modification/etc/sysconfig/network starts and shuts down the firewall1, immediate effect: #service iptables start#service iptables Stop2, restart the system to take effect: #service iptables on#service iptables off summarize network configuration: Configure IP, Gateway, DNS, and then restart the network.
http://www.cnblogs.com/starof/p/4153663.html#undefined

Linux network-related configuration files

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.