Linux server network configuration details 1. use the basic commands for Linux network configuration (1) Use the ifconfia command to configure and view the network connection n. on the Linux console, enter/bin/ifconfig. the displayed price information includes: Ethernet Card cthO, physical address: 00, EO, 4C-77, 2B t CS, IP Address: 10. 214. 33. 7.1 '': 10. 255. 255. 255. the subnet mask is 255.0.0.0. the Network Status of the device is MTU (maximum transmission unit) and Metric (degree basin optimization ). The Network statistics for interface communication are RX and Ding X. indicates the received and transmitted Packets, including packages, Errors, and Collisions ). the NIC interrupt source number is 201, and the port address is 0x2000. lo is a look-back network connection 11. represents the local machine. the IP address is 127.0.0. i. the subnet mask is 0.0.0.ifconfig. activate the device at the same time. # ifconfig ethO 192. 168. 4. 1 netmask 255. 255. 255.0 up ② configure the IP address of the device eth0, 1, and add the rh path. # ifconfig cth0, 1 192. 168.4. 2. route add-host 192. 168. 4. 2 dev ethO I ③ disable the device. # ifconfig ethO, I up (down) ④ view all (specified) Network Interface Configuration basin. # Ifconfig (ethO) (2) use the route command to configure the tree route table. Rout. Run the command: ⑥ add to host Lushan. # Route add-host 192. 168.4.2 dev ethO 'l indicates the route added to the network by route add-host 192. 168.4. 1 gw 192. 168.4. 250O. # Route add-net IP netmask MASK ethO # route add-net IP netmask MASK gw IP # route add a net IP/24 ethl 3 add a prison gateway. # route add default gw IP ④ route division. # route del host 192. 168. 4. 1 dev ethO, 1 ⑤ view route information. # Route or route-n (-n indicates that the name is not parsed. The list speed is faster than route) (3) netstat network status command. The netstat command is used to display various network-related status information. It is mainly used to view the network connection status in the shell, check the configuration information of the interface, check the night route table, and obtain statistical information. If the parameter is not specified, the value w indicates the obtained TCP and UDP u status. Because UDP is a connectionless protocol, the status is meaningless to it. Typical use of the netstat command: 1. Display Ethernet pricing and all protocols. # netstat-e-s 2. Display TCP and UDP statistics. # Netstat-s-p tcp udp 3. wait 5 seconds to display the active TCP connection and process ID. # netstat-o 5 4. run the active TCP connection and process 1D, # netstat-n-o (4) arp management command in the form of Z. 1. check arp-level memory. x arp ② Add a network user) ', # arp 1: ip mac ③ delete a 1P address user. youarp-d IP (5) ip is a powerful network length tool in iproute2 software package. it can replace some traditional network management tools, such as ifconfig and route. The above example can be fully implemented using the following ip commands. in addition, ip allows more functions. the syntax of the ip command is as follows: ip [OPTIONS] OBJECT [COMM 8 ND [ARGUMEN Ding S] some typical operation statements are listed below: oup/down start/Close the device. # ip link set dev eth0 up. this is equivalent to the traditional # ifconfig ethO up (down ). Change the length of the device transfer queue. parameter; txqucuelen NUMBER or txqlen NUMBER-# ip link set dev ethO txqueuelen 100 ③ optimizes network device MTU (DRUM Transmission Axis unit. # ip link set dev ethO mtu 1500 ④ modify the MAC address of the network device. Parameters. address LLAI) DRESS # ip link set dev ethO address, 4f. 91 ". 15. fl ip link show-display device properties. 1. The option appears twice or more times. The ip address will output more detailed error statistics. ⑤ S: ip-s, link Is ethO t mtu 1500 qdisc cbq glen 100 link/ether 00: a0: cc: 66. 18. 78 brd ff: ff RX. bytes packets errors dropped overrun mcast 2449949362 2786187 0 0 0 RX errors, length ere frame fifo missed 00000 TX. bytes packets errors dropped carrier collsns 178558497 1783946 332 0 332 35172TX errors: aborted fifo window heartbeat000332 this command is equivalent to the traditional ifconfig ethO. (6) ip route add-add New route. ip route change 1 modify route 1 11.ip route replace-replace existing route. ① The route destined for 10.0.0/24 goes through gateway 193.233. 7.65. # ip route add 10.0.0/24 via 193. 233. 7. 65 ② modify the direct route to the network 10.0.0/24 so that it passes through the device dummy. # ip route chg 10. 0. 0/24 dev dummy ③ achieve link load balancing. Add the default multi-path Path to share the load between ppp0 and pppl (Note: The scope value is not required. It only tells the kernel that this route must be connected through the gateway rather than Xiao. In fact, if you know the address of the remote endpoint, it would be better to set the value of "yellow" using the number of "via". # Ip route add default scope global nexthop dev ppp0 nexthop dev pppl # ip route replace default scope global nexthop dev ppp0 nexthop dev pppl ④ set carbon NAT Mountain. For example. in forwarding from 192. 203. 80. before the 144 packet, first convert the network address to 193. 233. 7.83. well ip route add nat 192. 203. 80. 144 via 193. 233. 7. 83 5. load Balancing at the packet level. packets can be randomly sent from multiple routes. You can set W weight for weight. # Ip route replace default equalize nexthop via 211. 139. 218. 145 dev ethO weight 1 nexthop via 211. 139. 218. 145 dev ethl weight I (7) configure the NIC. Configure It file/etc/sysconfig/network-scripts/ifcfg-eth0 with vi edit that. the following is a typical V command: DEVICE = cth0 1: DEVICE name. ONBOOT = yes is the same as the file at system startup. start BOOTPROTO-static IPADDR = 202. 118. 75. 91 # 1P address of this Nic NETMASK = 255.255. 255.0; mask GATEWAY = 202. 118. 75.1 l: gateway ip macaddr = 00. 02. 2D. 2E. SC. a8 # mac address