Linux Network Services Chapter One network infrastructure settings

1. notes

systenctl restart network: Restart card network services

bash: Refresh Host Name

netstat: View network status

route -n: do not do address resolution

mii-tool eno16777728: View Link

 

2.ifconfig command information contained in : 

Link encap: Ethernet Ethernet ⽹ HWaddr: a physical address (MAC address)

inet addr: IPv4 address Bcast: Wide-broadcast address Mask: Mask submenus ⽹

inet6 addr: IPv6 address

 

3. Open networks temporarily modify the configuration

( 1) Remedies ⼀: ifconfig Open networks device IP address [/ short format Submenu ⽹ mask]

( 2) Remedies ⼆: ifconfig Open networks device IP address [netmask Submenu ⽹ mask]

[root@localhost ~]# ifconfig ens32 192.168.200.111

[root@localhost ~]# ifconfig ens32 192.168.200.111/24

[root@localhost ~]

 

4. Open networks arranged to modify the fixed

( In ifcfg- Open networks corresponding to the device name in the / etc / sysconfig / network-scripts / of Contents: 1) Configuration File

Said first frame by default block ⽹ card ens32 or ens33

( 2) Configuration File Edit: before ⾯ band # represents the contents necessary configuration comes in handy

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens32

BOOTPROTO = static # boot protocol (DHCP: automatically acquiring; static / none: the watch movement

Configuration)

DEVICE = ens32 # device name

ONBOOT = yes # if the boot is automatically activated

IP address IPADDR = 192.168.200.111 # IPv4 protocol

PREFIX = 24 # submenus ⽹ mask

GATEWAY = 192.168.200.1 # ⽹ off

DNS1 = 202.106.0.20 #DNS Domain Name Service

HWADDR = 00 ^ 0C ^ 29 ^ 8F: D8 ^ E0 # physical address (MAC address)

 

5. Check network connection is provided where the command netstat 

Frequently-used options:

-a: Displays the current host Open networks all active connection information

-n: display information in digital form

-r: Displays the routing table information

-t: display information related to the TCP protocol

-u: Displays information UDP protocol

-p: display and network connection is provided associated process ID, process name information (requires root privileges)

-l: View monitor the status of the network connection is provided information

 

6.ping, traceroute command

Open networks connectivity test ping command

Frequently-used options:

Specifies the number of transmitted packets: -c

-i: When the ping, the number of seconds specified interval to record the next data packet transmission

-w: When ping fails, each data packet transmitted specified timeout in seconds

-s: specify the packet zoomed ⼩

Way to track the route data packets traceroute command

-n: Do not Perform reverse DNS lookup directly display the numeric IP address

 

7. often ⻅ of TTL (Time To Live) period value stored ⽣: 

windows:128

linux:64

unix:255

cisco:255

 

8. temporary card Submenu-connector provided ⽹

Remedies: the ifconfig Open networks equipment: Submenu Connector name IP address / mask short format Submenu ⽹

[root@localhost ~]# ifconfig ens32^0 192.168.1.1/24

[root@localhost ~]# ifconfig ens32:sec 192.168.2.1/24

9. permanently set ⽹ card-connector Submenu

( 1) Remedies: moving the watch needs to add configuration files in the / etc / sysconfig / network-scrips / of Contents

[root@localhost~]#vim/etc/sysconfig/network-scripts/ifcfg-ens32^0

 

10. The state of temporary modification of the card ⽹

( 1) Remedies: ifconfig Open networks apparatus up / down

[root@localhost ~]# ifconfig ens32 down && ifconfig ens32 up

 

11. Open networks reload configuration files

( 1) Restart Open networks and services in order to achieve re-read the configuration files of the destination time

⽅法:systemctl restart network = service network restart

[root@localhost ~]# systemctl restart network

( 2) modify a configuration block ⽹ card, only to restart the card ⽹

Format: ifdown device Open networks; the ifup Open networks equipment

[root@localhost ~]# ifdown ens32 ;

 

12. Temporary modify the hostname 

The new hostname hostname

[root@localhost ~]# hostname crushlinux.com

[root@localhost ~]# bash

[root@crushlinux ~]# hostname

crushlinux.com

 

13. permanently modify the hostname

Remedies 1: edit / etc / sysconfig / network configuration files, reboot the system efficiency ⽣

[root@crushlinux ~]# vim /etc/sysconfig/network

# Created by anaconda

HOSTNAME=crushlinux.com

Remedies 2: edit / etc / hostname configuration files, restart ⽣ effect (recommended)

[root@crushlinux ~]# vim /etc/hostname

crushlinux.com

 

14. The temporary configuration routing

( 1) temporarily add, delete the specified route segment recorded ⽹

Remedies: route segment ⽹ the Add -net / short format Submenu ⽹ gateway address mask gw ⽹

⽹ segment route del -net / Submenu ⽹ short format mask

[root@crushlinux ~]# route add -net 192.168.2.0/24 gw 192.168.200.1

[root@crushlinux ~]# route -n

[root@crushlinux ~]# route del -net 192.168.2.0/24

( 2) temporarily add, delete the default ⽹ off record

Remedies: route the Add default gateway address gw ⽹

route del default gw gateway address ⽹

[root@crushlinux ~]# route del default gw 192.168.200.1

 

15. Routing permanent configuration

( 1) Remedies ⼀: Add the /etc/rc.local

[root@crushlinux ~]# vim /etc/rc.local

route add -net 192.168.2.0/24 gw 192.168.200.1

route add -net 192.168.2.0/24 dev ens32

( 2) Remedies ⼆: Add to the end of the / etc / sysconfig / network in

Note: The configuration files ⽹ card ⽹ set off if the priority of the file to this configuration files ADVANCED

[root@crushlinux ~]# grep "GATEWAY" /etc/sysconfig/network-scripts/ifcfg

ens32

GATEWAY=192.168.200.1

( 3) Remedies three: Modify / etc / sysconfig / static-routes configuration files (which files the watch without moving building

⽴)

[root@crushlinux ~]# vim /etc/sysconfig/static-routes

any net 192.168.1.0/24 gw 192.168.200.1

any net 192.168.2.0 netmask 255.255.255.0 gw 192.168.200.1

[root@crushlinux ~]# systemctl restart network

[root@crushlinux ~]

( 4) Remedies Four: open IP forwarding (routing)

1> echo "1"> / proc / sys / net / ipv4 / ip_forward (temporary open)

2> /etc/sysctl.conf edit files will net.ipv4.ip_forward = 0 to 1 (permanently turned on)

sysctl -p (so sysctl.conf files attention immediately ⽣ efficiency) temporary opening

[root@crushlinux ~]# cat /proc/sys/net/ipv4/ip_forward

0

[root@crushlinux ~]# echo 1 > /proc/sys/net/ipv4/ip_forward

Permanently open

[root@crushlinux ~]# vim /etc/sysctl.conf

net.ipv4.ip_forward = 1

[root@crushlinux ~]# sysctl -p

 

16. Set the DNS resolution. 

( Configuration File Edit / etc / sysconfig / network-scripts / Open networks of Contents the device: 1) Remedies ⼀

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens32

DNS1 = 202.106.0.20

( 2) Remedies ⼆: vi edit files /etc/resolv.conf

[root@crushlinux ~]# vim /etc/resolv.conf

# Generated by NetworkManager

nameserver 202.106.0.20

 

17. Local DNS host mapping files

( 1) Remedies: edit / etc / hosts files

( 2) Description: / etc / hosts files take precedence over DNS domain name resolution service, that is, if ⼀ domain names

In the existing mapping between hosts files, the ⾏ domain name resolution will no longer enter the DNS server. hosts File

A member ⼀ ip

 

 

Guess you like

Origin www.cnblogs.com/ZCQ123456/p/11348519.html