Ifconfig
Route
Ip
IP route
One, ifconfig command (view or configure IP)
1. View Network Connections
# ifconfig \ Show all active connections, not packet-disabled devices
Or
# IFCONFIG-A \ Show all active and inactive connections
Displays the connection for the specified interface
# ifconfig Eth1
2. Configure IP Address
# ifconfig eth1 192.168.0.1 netmask 255.255.255.
Or
# ifconfig eth1 192.168.0.1/24
3. Enable or disable the interface
# ifconfig eth1 down|up or # Ifdown eth1 \ Disable interface # IFUP eht1 \ Enable interface
Second, Route command (view or configure routing)
1, view the route, use-n can view the display route in the number format to avoid the reverse of the host name, resulting in a slow query.
# route-ndestination Gateway genmask Flags Metric Ref use Iface192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
Target Next hop address mask flag bit hop point ref which interface is used
2. Add route
(a), network routing
# route add-net 192.168.1.0/24 GW 172.16.1.106
(b), host routing
# route Add-host 192.168.1.110 GW 172.16.1.106
(c), default route
# route Add default GW 172.16.1.106 or # route add-net 0.0.0.0 GW 172.16.1.106
Check out these three newly created
destination gateway genmask flags metric Ref Use Iface192.168.1.110 172.16.1.106 255.255.255.255 UGH 0 0 0 eth0192.168.1.0 172.16.1.106 255.255.255.0 UG 0 0 0 eth00.0.0.0 172.16.1.106 0.0.0.0 ug 0 0 0 eth0
3. Delete a route
# route Del-host 192.168.1.110# Route del-net 192.168.1.0/24
Third, DNS configuration
The content can only be modified by configuration file:/etc/resolv.conf
; Generated by/sbin/dhclient-scriptsearch localdomain feng.com \ Search domain nameserver 172.16.0.2 \ DNS domain name server
One line of DNS, up to three DNS
************************************************************************************
With the development of the system above two kinds of commands, will slowly be replaced by the following two commands.
Ifconfig = IP
Route = IP route
IP command
1. IP link (view network connection or enable disable NIC)
(a), view network Connections
# IP link show [interace] \ \ Interface can be saved, omit to show all connections
(b), enable disable interface and turn off enable multicast
IP link Set Interface [up|down] [multicast On|off]
2. IP addr (IP address management)
Configure IP
Format: IP addr Add dev Interface Address [Label Interface_alias]
(a), configure an IP or multiple IP for eth1
# IP addr Add dev eth1 192.168.1.118/24
(b), eth1 alias eth1:0 Configure an IP
# IP addr Add dev eth1 192.168.0.12/24 label eth1:0
View the configured IP
# IP addr show eth1 \ \ View the configured IP, the IP configured by this command cannot use Ifconfig to view 3:eth1: <BROADCAST,MULTICAST> MTU Qdisc pfifo_fast STA Te down Qlen link/ether 00:0c:29:42:91:29 brd ff:ff:ff:ff:ff:ff inet 192.168.1.118/24 scope Global eth1 inet 192.168.0.12/24 Scope Global eth1:0
Remove the configured IP
# ip addr del dev eth1 192.168.1.118/24
Clear Configuration
# IP Addr Flush Interface [to net_address]
# IP addr flush eth1 \ \ \ \ \ \ \ \ \ \ \ All IP configuration of the NIC can be cleared
Or
IP addr flush eth0 to 192.168.0.0/24 \ \ As long as the IP of the same network segment and 192.168.0 will be cleared out
Or
IP addr flush eth0 192.168.16.19/24 \ \ Only clears the specified IP
3. IP Route Routing Configuration
IP route
(a), view routing configuration
# IP route Show or IP route
(b), configure routing
IP route add DESTINATION [via Next_hop] [src source_address] [Dev DEVICE] #
# IP route add 192.168.1.0/24 via 172.16.1.106
If the NIC is configured with more than one IP, you can specify which network card the packet is from.
# IP route add 192.168.1.0/24 src 172.16.1.106 dev eth1
# ip route show192.168.1.0/24 dev eth1 scope link src 172.16.1.106
(c), delete route
# IP Route del 192.168.0.1/24
This article is from "Rookie Diary" blog, please make sure to keep this source http://zkxfoo.blog.51cto.com/1605971/1758528
Linux Network Configuration Command ifconfig, route, IP, IP route