Linux network settings (version 2)-Linux network settings

Source: Internet
Author: User
Tags name database

Linux network settings (version 2)-Linux network settings
Linux network settings-network configuration file and command network configuration file

1./etc/sysconfig/network-scripts/ifcfg-eth0 # [Save the IP address and gateway]

[Set static IP addresses]

IPADDR = new IP address # This option sets the IP address. If BOOTPROTO = dhcp is set and the IP address is automatically obtained, this option is not available. Otherwise, it is BOOTPROTO = no.

GATEWAY = GATEWAY # specify a GATEWAY

BROADCAST = BROADCAST address

NETMASK = Subnet Mask

2./etc/sysconfig/network # Save the local host name

HOSTNAME = host name # specify the host name. If dhcp is specified for automatic allocation, this option is not available because the host names are all localhost.

3./etc/rc. d/init. d/network start/stop/restart network Startup Script

Or service network restart

If a static IP address is set, restart the system, or reload the following STARTUP script. The setting takes effect. However, the latter is recommended!

4./etc/hosts # saves the domain name database

5./etc/services # stores network service information, such as ports and transmission protocols.

6./etc/resolv. conf # specify the DNS server address

Nameserver [DNS Server IP address] # Add a DNS server. You can specify multiple DNS server addresses with spaces. Up to three DNS server addresses can be used.

Appendix-the service program may not use a fixed port, but the WebServer exposed to the outside will not change the port, but it is recommended to change the port like SSH to avoid Scanning

Nmap [IP address] # scan the host to enable those services, but it only scans the ingress port or the port of the well-known service by default.

Network management commands

1. ifconfig # view network port settings

Ifconfig eth0 up/down # enable/disable the NIC

2. ethtool [Nic name] # detect Nic line connection

Ethtool eth0

Ethtool wlan0

The ethtool command is very important when multiple NICs exist on a server!

3. arp # view ARP table information, as shown in the preceding figure.

4. ping # detect remote hosts

Ping-c 10-s 1000 IP address #-c specifies the number of ping requests, and-s specifies the size of sent packets. Pay attention to the packet loss rate during ping.

5. route # operate the route table

Route add default gw 192.168.14.100 # add a gateway without modifying the configuration file

[But it is better to modify the configuration file]

Zerba routing software]

6. traceroute # view the route path

Traceroute www.163.com # it lists all the routers and latencies that pass through the host.

7. netstat # monitor the network status

Netstat-an # view all connections

Netstat-an | grep: 80 # Check whether the Apache service is started

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.