Basic network configuration in Linux-general Linux technology-Linux technology and application information. For details, refer to the following section. 1. Basic configuration file
/Etc/hosts
Simple text file that associates IP addresses with host names
127.0.0.1 nameserver localhost. localdomain localhost # complete IP address host name alias
/Etc/services
The relationship between the port number and the standard service. Programs on the server and client can convert the service name to the port number.
#21 is registered to ftp, but also used by fsp
Ftp 21/tcp
Ftp 21/udp fsp fspd # host service name port number/port type alias
Ssh 22/tcp # SSH Remote Login Protocol
Ssh 22/udp # SSH Remote Login Protocol
Telnet 23/tcp
Telnet 23/udp
/Etc/sysconfig/network
Used to specify the desired network configuration information. (The network configuration of the host, not for a certain device)
NETWORKING = yes
HOSTNAME = nameserver
2. executable scripts and commands
/Etc/rc. d/init. d/network {start | stop | restart | reload | status} = service network restart
The initialization script program when the system starts. Mainly calls scripts related to/etc/sysconfig/network-scripts/directory
/Etc/sysconfig/network-scripts/ifdown |/etc/sysconfig/network-scripts/ifup
It is actually calling/sbin/ifup or/sbin/ifdown
Parameter configuration file/etc/sysconfig/networking/devices/ifcfg-eth0
DEVICE = eth0
BOOTPROTO = none
BROADCAST = 192.168.10.255
IPADDR = 192.168.10.5
NETMASK = 255.255.255.0
NETWORK = 192.168.10.0
ONBOOT = yes
USERCTL = no
PEERDNS = no
TYPE = Ethernet
Ifconfig
It is used to set or read network device parameters in the system kernel table.
Displays, activates, and disables network devices. displays, adds, and deletes network device addresses and statuses.
Ifconfig -- help # syntax
Usage:
Ifconfig [-a] [-I] [-v] [-s] [[]
[Add [/ ]
[Del [/ ]
[[-] Broadcast [] [[-] pointopoint []
[Netmask] [dstaddr] [tunnel]
[Outfill ] [Keepalive ]
[Hw ] [Metric ] [Mtu ]
[[-] Trailers] [[-] arp] [[-] allmulti]
[Multicast] [[-] promisc]
[Mem_start ] [Io_addr ] [Irq ] [Media ]
[Txqueuelen ]
[[-] Dynamic]
[Up | down]...
# Ifconfig # view Nic Parameters
# Ifconfig eth0 up | down # Start | disable the NIC
# Ifconfig eth0 192.168.0.2 netmask 255.255.255.0 # Set an IP address for the NIC
Netconfig # Network Device Configuration tool. Write configuration parameters to/etc/sysconfig/network-scripts/ifcfg-eth0
Redhat-config-network gui # graphical interface
System-config-network-cmd tui # AS4 command
**************************************** **************************************** *******
Supplement:
# Ifconfig eth0 hw ether xx: xx # manually change the MAC address of the NIC
# Ifconfig eth0: 0 192.168.200.9 netmask 255.255.255.0 broadcast 192.168.200.255 # Add an IP address (eth0 alias, eth0: 0, eth0: 1 ,.......)
Two NICs: add the following to/etc/modules. conf:
Alias eth1 ne-pci
/Etc/sysconfig/networking/devices/ifcfg-eth0 # after modification to/etc/rc. d/init. d/network restart takes effect
Netconfig # The modification takes effect only after/etc/rc. d/init. d/network restart.
Netconfig writes configuration parameters to/etc/sysconfig/network-scripts/ifcfg-eth0
Ifconfig # takes effect immediately after modification, but is lost after restart.
**************************************** **************************************** *******
3. Set the DHCP Client
1. Use netconfig
2. ifconfig-dynamic
3. Modify/etc/sysconfig/networking/devices/ifcfg-eth0
DEVICE = eth0
BOOTPROTO = none # = dhcp
Iv. DNS
Cat/etc/host. conf
Order hosts, bind
/Etc/nsswitch. conf
Passwd: files
Shadow: files
Group: files
Hosts: files dns # first check the hosts file and then the DNS
/Etc/resolv. conf
Nameserver 127.0.0.1 # DNS Server IP Address
Nameserver 192.168.10.5
Search test.com # domain name query order
V. Routing and network connectivity
Ping # connectivity test
Route # route settings and Management
# Route
# Route add-net 192.168.22.16netmask 255.255.255.0 dev eth0 # equivalent to the next command
# Route add-net 192.168.22.16netmask 255.255.255.0 gw 192.168.10.5
# Route del-net 192.168.22.16netmask 255.255.255.0
# Route-C # view the route cache table
# Route-n # view route information
Destination Gateway Genmask Flags Metric Ref Use Iface
61.235.103.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 61.235.103.1 0.0.0.0 UG 0 0 0 ppp0
Traceroute Route Test
# Traceroute yahoo.com.cn
1 ***
2 61.235.96.165 (61.235.96.165) 2.663 MS 1.709 MS 1.551 MS
3 61.235.96.129 (61.235.96.129) 1.773 MS 1.847 MS 1.755 MS
# Arp # view arp cache
Address HWtype HWaddress Flags Mask Iface
192.168.10.100 ether 00: 14: 85: DC: 3D: 3A C eth0
# Hostname # view and change the Host Name
Nameserver
# Netstat # view IP protocol status, socket, interface status, etc.
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
Tcp 0 2 192.168.10.5: telnet 192.168.10.100: xtel ESTABLISHED
Tcp 0 0 nameserver: 33606 nameserver: ipp TIME_WAIT
Tcp 0 0 nameserver: 33607 nameserver: ipp TI
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