[root@localhost ~]# ip addr show 查看mac IP地址
[root@localhost ~]# ip a
[root@localhost ~]# ping 192.168.147.128
PING 192.168.147.128 (192.168.147.128) 56(84) bytes of data.
64 bytes from 192.168.147.128: icmp_seq=1 ttl=64 time=0.068 ms
ttl time to live(生存时间) 跳数
[root@localhost ~]# route -n #查看路由类型
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.147.2 0.0.0.0 UG 100 0 0 ens33
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
192.168.147.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33
192.168.147.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
[root@localhost ~]# arp -n #显示本地ARP缓存中的条码
Address HWtype HWaddress Flags Mask Iface
10.10.10.10 ether 00:0c:29:35:d8:75 C ens33
192.168.147.2 ether 00:50:56:e0:9f:61 C ens33
192.168.147.254 ether 00:50:56:e2:7b:4e C ens33
192.168.147.1 ether 00:50:56:c0:00:08 C ens33
[root@localhost ~]# ethtool ens33 #显示网络接口相关信息
[root@localhost ~]# arping 192.168.147.128 #获取对方的mac地址
跨网段通信
关闭NetworkManager
[root@localhost ~]# systemctl stop NetworkManager
方式一:
网关:开启转发(临时)
[root@localhost ~]# echo 1 > /proc/sys/net/ipv4/ip_forward
[root@localhost ~]# cat /proc/sys/net/ipv4/ip_forward
A主机的默认网关 指向 192.168.147.222
[root@localhost ~]# route del default gw 192.168.147.2
[root@localhost ~]# route add default gw 192.168.147.222
B主机的默认网关 指向10.10.10.222
[root@localhost ~]# route del default gw 10.10.10.2
[root@localhost ~]# route del default gw 10.10.10.222
方法二:静态路由
主机1:192.168.147.128
[root@localhost ~]# route add -net 10.10.10.0 netmask 255.255.255.0 dev ens33
删除
[root@localhost ~]# route del -net 10.10.10.0 netmask 255.255.255.0 dev ens33
主机2:10.10.10.10
[root@localhost roobit]# route add -net 192.168.147.0 netmask 255.255.255.0 dev ens33
删除
[root@localhost roobit]# route del -net 192.168.147.0 netmask 255.255.255.0 dev ens33