Linux basic network settings

First, the content of points:

1, view network settings

2, test the network connection

3, using a network configuration commands

4, modify the network configuration file

Second, view network settings

1, view network interface information ifconfig

View all active network interfaces

  • Ifconfig command is executed

  • image.png

  • Check the specified network interface information

  • ifconfig network interface number

  • 2, view the host name hostname

[Root @ localhost ~] # hostname hostname View

image.png

[Root @ localhost ~] # hostnamectl set-hostname http01 modify the hostname   

image.png

3, check the routing table entry route

route command: To view or set the host routing table information

route [-n] or direct route

image.png

4, check the network connectivity netstat

netstat command: network connection status viewing system, routing tables, interface statistics and other information

netstat [options]

Common options

  • -a: List all

  • -n: Digital Representation

  • -p: Agreement

  • -t: lists tcp connection protocol

  • -u: list udp protocol connection

  • -r: lists the routing table information

neistat -ntap View all tcp protocol interface information represented in digital form

image.png

neistat -nuap View all udp protocol interface information represented in digital form

image.png

neistat -r to see the routing table information, like route

image.png

Third, test the network connection

a, ping command: to test network connectivity

ping [options] target host

image.png

b, with trace packets traceroute

traceroute command: test (used to determine fault) current from passing between the host to the destination host a network node

tracerouter target host address

c, DNS nslookup

nslookup command: Testing DNS resolution.

nslookup target host address
image.png

Fourth, set network parameters manner

1, temporary configuration - adjust the network parameters using the command

  • Simple, fast, can directly modify the operation of the network parameters

  • Generally only suitable for use in the process of debugging the network

  • After a system reboot, your changes will fail

2, fixed - to modify the network configuration file parameters

  • Modify the configuration file of the network parameters

  • Suitable for use when fixed parameter settings server

  • Network services need to reload or restart to take effect later

1, a network interface parameters ifconfig

a, set the network interface IP address, subnet mask (provisional setting)

ifconfig interface number IP address [netmask Subnet Mask]

ifconfig network interface IP address [/ mask length]

image.png

b, disabled or re-activate the card

ifconfig network interface up

ifconfig network interface down  

image.png

C, is provided a virtual network interface (NIC a different public ip, implement multiple IP addresses)

ifconfig interface number: Serial number IP address

image.png

2, set the record route route

a, add a route to the specified recording segment

route add -net network address gw IP address

image.png

b, delete the route to record the specified network.

route del -net network address

image.png

Default Gateway record c, delete routing table

route del default gw IP address

 d, default gateway records added to the routing table

route add default gw IP address

image.png

Guess you like

Origin blog.51cto.com/14475876/2434816