Linux Network Basic Configuration

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

I. Network configuration file
1./ETC/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-ETHN (n for ...)
The first Nic Ifcfg-eth0, the second NIC Ifcfg-eth1 ...
File parameters:
*device Interface Name (device, NIC)
*userctl [Yes|no] (whether the device can be controlled by a non-root user)
*bootproto IP Configuration method [None|static|bootp|dhcp] (No protocol at boot | Static allocation ip| BOOTP protocol | DHCP protocol)
*hwaddr MAC Address
*onboot the network interface is active when the system is started (yes/no)
*type network type (usually Ethemet)
*netmask Network Mask
*IPADDR IP Address
*ipv6init IPV6 is valid (yes/no)
*gateway Default gateway IP address
*broadcast Broadcast Address
*network Network Address
You can refer to the following example = = = = =

*device=eth0
*bootproto=static
*broadcast=192.168.1.255
*hwaddr=00:0c:2x:6x:0x:xx
*ipaddr=192.168.1.23
*netmask=255.255.255.0
*network=192.168.1.0
*onboot=yes

2./etc/resolve.conf
DNS Client configuration file, setting the IP address and DNS domain name of the DNS server
Domain xxx.com
Search Www.xxx.com xxx.com
NameServer 202.102.192.68
NameServer 202.102.192.69
The most important is the nameserver keyword, if you do not specify nameserver can not find the DNS server, other keywords are optional.
NameServer indicates that the host specified with this address is the domain name server when resolving the domain name. The domain name servers are queried in the order in which they appear in the file, and the following nameserver are queried only if the first nameserver is unresponsive.
Domain declares the name of the host. Many programs use it, such as a mail system, and are used when DNS queries are made for hosts that do not have a domain name. If there is no domain name, the hostname is used, removing all at the first point (.) The previous content.
Search its multiple parameters indicate the order of the domain name query. When you want to query a host that does not have a domain name, the host is found separately in the domain that is declared by search.
Domain and search cannot coexist, and if they exist at the same time, subsequent occurrences will be used.

3./etc/host.conf
This file specifies how the host name is resolved. Linux uses the parser library to obtain the IP address of the host name. The following is an example of a "/etc/host.conf":
Order Bind,hosts
Multi on
Nospoof on
"Order Bind,hosts" specifies the host name Query order, where DNS is used to resolve the domain name before querying the "/etc/hosts" file (or vice versa).
"Multi on" Specifies whether the host specified in the "/etc/hosts" file can have more than one address, and a host with multiple IP addresses is generally referred to as a multi-homed host.
"Nospoof on" means IP address spoofing is not allowed on this server. IP spoofing is a means of attacking system security by disguising IP addresses as other computers to gain trust from other computers.

4./etc/sysconfig/network
The main function is to set the "host name (HOSTNAME) and start Network or not"! In general, if you change the host name in this file, be sure to turn it back on (reboot), because this will allow all the programs above the system to use the latest set of host names.
Set the basic network configuration, including the host name, Gateway and other information, the following is the contents of the file.
Networking=yes
Hostname=duzhan
gateway=192.168.1.2
NETWORKING: Used to set whether the Linux network is running, yes is running, no is not running
HOSTNAME: The name of the host, the name above us is Duzhan
Gateway: IP Address for gateways


5./etc/hosts
When the machine starts, before DNS can be queried, the machine needs to query for some host name to IP address matching. These matching information is stored in the/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.
The following is an example of a "/etc/hosts" file:
127.0.0.1 Localhost Gate.openarch.com
208.164.186.1 www.it.com www
The leftmost column is the host IP information, and the middle column is the host name. Any subsequent columns are aliases for that host.

Once you have configured your machine's network configuration file, you should restart the network for the changes to take effect.


6./etc/services
is a service name and data corresponding to the service port
Library files
#/etc/services:
# $Id: services,v 1.43 2007/04/18 08:40:12 Pknirsch EXP $
#
# Network Services, Internet style
#
# Note that it's presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; Hence, most entries here has a entries
# Even if the protocol doesn ' t support UDP operations.
# Updated from RFC 1700, ' Assigned Numbers ' (October 1994). Not all ports
# is included, only the more common ones.
#
# The latest IANA port assignments can be gotten from
# http://www.iana.org/assignments/port-numbers
# The well known Ports is those from 0 through 1023.
# The registered Ports is those from 1024x768 through 49151
# the Dynamic and/or Private Ports is those from 49152 through 65535
#
# Each line describes one service, and is of the form:
#
# service-name Port/protocol [aliases ...] [# Comment]
Service Name Port/Protocol alias comment
Tcpmux 1/tcp # TCP Port Service multiplexer
Tcpmux 1/UDP # TCP Port Service multiplexer
Rje 5/tcp # Remote Job Entry
Rje 5/udp # Remote Job Entry
Echo 7/tcp
Echo 7/UDP
Discard 9/tcp sink NULL
Discard 9/udp sink NULL
Systat 11/TCP Users
Systat 11/UDP Users
Daytime 13/TCP
Daytime 13/UDP
QOTD 17/TCP Quote
QOTD 17/UDP Quote
MSP 18/TCP # Message Send protocol
MSP 18/UDP # Message Send protocol
Chargen 19/tcp TTYTST Source
Chargen 19/udp TTYTST Source
Ftp-data 20/tcp
Ftp-data 20/UDP
# Registered to FTP, but also used by FSP
。。。。。。。。。。。。。。。


Two. Network commands
1.traceroute--show the path between packets to the target host
Traceroute-n URL directly using IP address

2.ifconfig--displaying and setting the IP address of the network card
Parameters
Up starts the specified network device/NIC.
Down to turn off the specified network device/NIC. This parameter can effectively block the IP traffic through the specified interface, and if you want to permanently shut down an interface, we also need to remove all the routing information from the core routing table from that interface.
netmask< Subnet mask > Set subnet mask for network card. The mask can be a 32-bit hexadecimal number with a prefix of 0x, or 4 decimal digits separated by dots.
# ifconfig eth0 192.168.120.56 netmask 255.255.255.0
Configure IP address for eth0 NIC: 192.168.120.56, plus child mask: 255.255.255.0

3.ping--connectivity between the test and the target computer
Parameters
-C: Set the number of responses required to complete
-I: Specify the time interval between sending and receiving information
-S: Set the size of the packet


The 4.netstat--command is used to display various network related information, such as network connection, routing table, interface status (Interface Statistics), masquerade connection, multicast member (multicast memberships)
Parameters
-A (All) displays all options and does not show listen related by default
-T (TCP) displays only TCP-related options
-U (UDP) displays only UDP-related options
-N refuses to display aliases, showing all numbers converted to numbers.
-l list only service status in Listen (listening)

-P Displays the program name that establishes the associated link
-R display routing information, routing table
-e display extended information, such as UID, etc.
-S statistics according to each protocol
-C executes the netstat command every other fixed time
Instance:
# Netstat-at
List all TCP ports Netstat-at
# Netstat-au
List all UDP ports Netstat-au
# netstat-l
Display only the listening port netstat-l
# netstat-pt
Show PID and process name in netstat output
# Netstat-r
Show Core Routing information

5.arp--adding, deleting, and displaying ARP caches
Parameters
-A: Displays the current ARP cache information for the specified host
-S: Create an ARP cache
-D: Delete an ARP cache

6.tcpdump--monitor TCP/IP connections and directly read the Data link layer header
#tcpdump-I. eth0
Reads the packet header of the data link layer using the specified network interface

Three. Manage Network services
1.ntsysv--configuration lets services start or stop automatically when the system starts

2.chkconfig--the start, stop, and restart of the control service, which takes effect after the computer restarts
Chkconfig--list [service name]
Displays the health status information for all/specified run level services

Chkconfig--add [service name]
Add a new service

Chkconfig--del [service name]
Delete the service and remove the associated symbolic link from the/ETC/RC[0-6].D directory

Chkconfig [--level levels] [service name] [On|off|reset]
Sets whether a service is started, stopped, or restarted at a specified runlevel
Example: #chkconfig--level 345 named on
Start the named service on the RunLevel 3,4,5


3.service--Control service start, stop, and restart, will take effect immediately
service [name] [Start|restart|stop|status]
Start: Start the service
Restart: Restart Service
STOP: Stop service
Status: View service status

Linux Network Basic 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.