#ifconfig命令: used to view and configure network devices
Displays information about the network interface for the current activation state:
[[Email protected]_168_102_centos ~]# ifconfigeth0 Link encap:ethernet hwadd R 00:16:3e:e2:7b:d2 inet addr: 10.221.168.102 bcast:10.221.171.255 Mask:255.255.252.0 Inet6 addr:fe80:: 216:3eff:fee2:7bd2/64 Scope:link up broadcast RUNNING multicast MTU: metric:1 RX packets: 3689339 errors:0 dropped:0 overruns:0 frame:0 TX packets:1724548 errors:0 dropped:0 overruns:0 carrier:0 collisions: 0 txqueuelen:10 00 RX bytes: 370517889 (353.3 MiB) TX bytes:211155888 (201.3 MiB) Interrupt: 163 simple description:
Eth0: Network interface
Link encap: Network type
HWADDR: Network card Physical Address (MAC address)
Inet ADDR:IP Address
Bcast: Broadcast Address
Mask: Subnet Mask
Up: Represents the network card is on; RUNNING: Network cable that represents the NIC is connected; broadcast: Supports point-to-point communication protocol; multicast: Support multicast
MTU: The maximum transmission unit of the NIC
RX Packets: Number of packets received
TX Packets: Number of packets transmitted
RX byte: The exact number received
TX byte: The exact number of transmissions
Interrupt: Terminal information
Lo Link encap:local Loopback inet addr:127.0.0.1 mask:255.0.0.0 inet6 addr::: 1/128 Scope : Host up LOOPBACK RUNNING MTU:16436 metric:1 RX packets:errors:0 dropped:0 overruns:0 frame:0 TX packets:errors:0 dropped:0 overruns:0 carrier:0 collisions: 0 txqueuelen:0 RX bytes:1568 (1.5 KiB) TX bytes:1568 (1.5 KiB)
Lo: Local Loop interface
Displays the specified network interface:
[Email protected]_168_102_centos ~]# ifconfig eth0eth0 Link encap:ethernet 00:16: 3e:e2:7b:d2 inet addr:10.221.168.102 bcast:10.221.171.255 mask:255.255.252.0 inet6 addr:fe80::216:3eff:fee2:7bd2/64 scope:link up Broadcast RUNNING multicast MTU: metric:1 RX packets:3694095 errors:0 dropped:0 overruns:0 frame:0 TX packets:1725551 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:370998440 (353.8 MiB) TX bytes:211382468 (201.5 MiB) Interrupt:163
Configure the IP address (effective immediately, but not permanently):
Ifconfig eth0 192.168.122.22
Configure IP to eth0 NIC: 192.168.120.56
Ifconfig eth0 192.168.122.22 netmask 255.255.255.0 (or 192.168.122.22/24)
Configure IP address for eth0 NIC: 192.168.120.56, plus child mask: 255.255.255.0
To start/close the specified network interface:
Ifconfig eth0 on
Ifconfig eth0 Down
Set the maximum transmission unit:
[[email protected] ~]# ifconfig eth0 MTU 1480[[Email protected]~]# ifconfig eth0 eth0 Link encap:ethernet HWaddr00:0c:29:44:b7:60inet Addr:192.168.108.128 bcast:192.168.108.255 mask:255.255.255.0Inet6 addr:fe80::20c:29ff:fe44:b760/64scope:link up broadcast RUNNING multicast MTU:1480 Metric:1RX Packets:373 errors:0 dropped:0 overruns:0 frame:0TX Packets:275 errors:0 dropped:0 overruns:0 carrier:0Collisions:0 txqueuelen:1000RX Bytes:37682 (36.7 KiB) TX bytes:35735 (34.8KiB) [[Email protected]~]# ifconfig eth0 MTU 1500[[Email protected]~]# ifconfig eth0 eth0 Link encap:ethernet HWaddr00:0c:29:44:b7:60inet Addr:192.168.108.128 bcast:192.168.108.255 mask:255.255.255.0Inet6 addr:fe80::20c:29ff:fe44:b760/64scope:link up broadcast RUNNING multicast MTU:Metric:1RX Packets:399 errors:0 dropped:0 overruns:0 frame:0TX Packets:293 errors:0 dropped:0 overruns:0 carrier:0Collisions:0 txqueuelen:1000RX Bytes:39932 (38.9 KiB) TX bytes:38155 (37.2 KiB)
#route命令: For displaying and manipulating IP routing tables
Show current routing information:
[Email protected] ~]# Route
Kernel IP Routing tabledestination Gateway genmask Flags Metric Ref use Iface192.168.108.0 * 255.255.255.0 U 0 0 0 eth0192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0
Brief description:
Destination: Target host or target network
Gateway Address (* indicates that the target is the network to which this host belongs and does not require routing)
Genmask: Network Mask
Flags Flag Description: U:up indicates that this route is currently in the boot state; H: Indicates that the target is the host; G: Indicates that the route is pointing to the gateway
Metric: Routing distance, number of relays required to reach the specified network (not used in the Linux kernel)
REF: Number of route entry references (not used in the Linux kernel)
Use: The number of times the route is used, which can roughly estimate network traffic to the specified network address
Iface: Output interface
Route-n: Use number format to display, do not reverse address to host name
Routes added to the host:
[[email protected] ~]# Route add-host 192.168.107.1 GW 192.168.108.25~]# route-nkernel IP Routing Tabledest Ination Gateway genmask Flags Metric Ref use Iface192.168.107.1 192.168.108.25 255.255.255.255 UGH 0 0 0 eth0192.168.108.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 Virbr0
Routes added to the network:
Route add-net 10.20.30.48 netmask 255.255.255.0 GW 10.20.30.41
Route add-net 10.20.30.48/24 GW 10.20.30.41
Add to Default route
default GW 192.168.1.55192.168.107.1 192.168.108.25 255.255.255.255 UGH 0 0 0 Eth0192.168.108.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr00.0.0.0 192.168.108.55 0.0.0.0 UG 0 0 0 eth0
Route del: Delete route
Remove a route to the host
[Email protected] ~]# route-nkernel IP Routing tabledestination Gateway genmask Flags Metric Ref use Iface192.168.107.1 192.168.108.25 255.255.255.255 UGH 0 0 0eth0192.168.108.0 0.0.0.0 255.255.255.0 U 0 0 0eth0192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0virbr00.0.0.0 192.168.108.55 0.0.0.0 UG 0 0 0Eth0[[email protected]~]# Route Del-host 192.168.107.1[[Email protected]~]# Route-nkernel IP Routing tabledestination Gateway genmask Flags Metric Ref use Iface192.168.108.0 0.0.0.0 255.255.255.0 U 0 0 0eth0192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0virbr00.0.0.0 192.168.108.55 0.0.0.0 UG 0 0 0 eth0
Remove routes to the network
Route Del–net 192.168.1.1
Remove to default route
[[email protected] ~]# route-nkernel IP routing tabledestination Gateway Genmask Flags Metric Ref use Iface 192.168.108.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0 0.0.0.0 192.168.108.55 0.0.0.0 UG 0 0 0 eth0[[email protected] ~]# route del default [[email protected] ~]# route-nkernel IP Routing TableDestination Gateway genmask Flags Metric Ref use Iface 192.168.108.0 0.0.0.0 2 55.255.255.0 U 0 0 0 eth0 192.168.122.0 0.0.0.0 255.255.255 .0 U 0 0 0 virbr0
#配置DNS
[Email protected] ~]# vim/etc/192.168.108.1
Linux Learning Commands Summary ⑩⑥