Linux Network Configuration
(CENTOS6 CENTOS7)
Article One
The Ifconfig command is used to view and configure network devices. Network environment changes This command configures the network accordingly.
[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0device= "eth0" NIC interface bootproto= "DHCP"              -DHCP Dynamic Protocol -static: Static protocol  -BOOTP protocol hwaddr= "00:0C:29:AB:DC:D7" network card MAC address nm_controlled= "yes" whether the NIC accepts NetworkManager control; CentOS6 recommended "no" onboot= "yes" whether the gateway= "is loaded automatically when the system starts" 192.168.1.0 " Nic Gateway address type=" Ethernet " NIC Type ipaddr=192.168.1.107 Network card IP address (static protocol needs to be set) netmask=255.255.255.0 Network address (static protocol needs to be set) BROADCAst=192.168.1.255 network card broadcast address uuid= "C05F7C37-2D21-4DB7-BE93-8A0DD2F661EC" [[ email protected] ~]# ifdown eth0 shut down the network [[email protected] ~]# ifup eth0 Start Network [[email protected] ~]# service network stop shutting down network services [[email protected] ~]# service network start Start Network Service [[Email protected] ~]# service network restart Restart Network Services
The route command is used to display and manipulate the IP routing table (show/manipulate the IP routing table)
Route add [-net|-host] target [netmask Nm] [GW GW] [[Dev] If]
[Email protected] ~]# Route add-host 192.168.1.107 GW 172.16.0.1 Dev eth1
Route del [-net|-host] target [GW GW] [netmask Nm] [[Dev] If]
[Email protected] ~]# Route del-host 192.168.1.106[[email protected] ~]# route del-net 192.168.0.0 netmask 255.255.255. 0
Route-n Viewing the routing table
{DNS server specified}
[Email protected] ~]# vi/etc/resolv.conf# Generated by Networkmanagernameserver 10.10.10.1nameserver 192.168.1.1
netstat-print network connections, routing tables, interface statistics, masquerade connections, and multicast Memberships (shows network connections, routing tables, interface statistics, spoofed connections, and multicast members)
[[email protected] ~]# netstat -t (TCP protocol Connection) Active internet connections (w/o servers) proto recv-q send-q local address Foreign Address State  TCP        0     52 192.168.1.105: ssh 192.168.1.102:55765 established [[email protected] ~]# netstat -u (link to UDP protocol) active internet connections (w/o servers) proto recv-q send-q local address foreign address state [[email protected] ~]# netstat -r (Show routing table, similar to route or Ip route show) kernel ip routing tabledestination gateway genmask flags mss window irtt Iface192.168.1.0 * 255.255.255.0 U 0 0 0 eth1default 192.168.1.1 0.0.0.0 ug 0 0 0 eth1
-L: Listening status connection
-A: Connections for all States
-P: Connection-related processes
-N: Number format display
SS, used to replace Netstat (advantage of UDP) digest
Connection to the-T:TCP protocol
Links to the-U:UDP agreement
-L: Listening status connection
-A: Connections for all States
-E: Show extended information
-M: Displays memory information used by the socket connection
-P: Process and UDP
-N: Number format display
-O State (established)
Chapter Two
Configure Linux Network properties: IP command
[[email protected] ~]# ip -s link show1: lo: <loopback,up,lower_up> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 rx: bytes packets errors dropped overrun mcast 1312 24 0 0 0 0 tx: bytes packets errors dropped carrier collsns 1312 24 0 0 0 0 2: eth1: < Broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state up qlen 1000 link/ether 00:0c:29:35:de:4e brd ff:ff:ff:ff:ff:ff RX: bytes packets errors dropped overrun mcast 98128879 139122 0 0 0 0 TX: bytes packets errors dropped carrier collsns 8388577 63333 0 0 0 0
[[Email protected] ~]# IP address [add|del] [IP parameters] [dev device name] [related parameters] parameter: Show: simply display the IP information of the device; Add|del: Add or delete the relevant parameter (add) (DEL) settings, mainly: IP parameters: The main is the network domain settings, such as 192.168.100.100/24 settings;
[[email protected] ~]# ip addr add 4.4.4.4/32 dev eth1 Label eth1:zhong [[email protected] ~]# ip addr show eth12: eth1: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state up qlen 1000 link/ether 00:0c:29:35:de:4e brd ff:ff:ff:ff:ff:ff inet 192.168.1.105/24 brd 192.168.1.255 scope global Eth1 inet 2.2.2.2/24 scope global eth1 inet 3.3.3.3/32 scope global eth1:1 inet 4.4.4.4/32 scope global eth1:zhong inet6 fe80::20c:29ff:fe35:de4e/64 scope Link valid_lft forever preferred_lft forever
[[Email protected] ~]# IP route show <== simple display of routing settings [[email protected] ~]# IP route [add|del] [IP or domain] [via gateway] [Dev Device][[email protected] ~]# IP route show2.2.2.0/24 Dev eth1 proto kernel scope link src 2.2.2.2 192.168.1.0/24 dev eth1 Proto kernel scope link src 192.168.1.105 metric 1 default via 192.168.1.1 dev eth1 proto static
Add routes that can be routed to the outside, via the route
Add default route IP route add default VIA[IP or domain] [dev Device]
Remove route IP route del [IP or domain]
"Takeaway"
/etc/sysconfig/network-scripts/route-IFACE Two styles of: (1) TARGET via GW (2) Define one route per three lines ADDRESS#=TARGET NETMASK#=mask GATEWAY#=GW Configure multiple address: for NIC ifconfig: ifconfig IFACE_ALIAS Ip ip addr add configuration file: ifcfg-IFACE_ALIAS device=iface_alias Note: The gateway alias cannot be booted using the DHCP protocol; linux Network Properties configuration for TUI (text user interface): system-config-network-tui can also use Setup to find; Note: Remember to restart the network service to be effective; Configure the host name of the current host: hostname [HOSTNAME] /etc/sysconfig/network HOSTNAME= network interface identifies and names the associated udev configuration file: /etc/udev/rules.d/70-persistent-net.rules uninstall NIC driver: modprobe -r e1000 Load network card driver: modprobe e1000
Article Three (CentOS7)
Address Configuration tool: Nmcli
(not to be continued)
This article is from the "Hotel California" blog, make sure to keep this source http://zhongshixun.blog.51cto.com/10314910/1691252
Linux Network configuration