[cshrimp-a300 ~]# virsh net-define nat1.xml Network nat1 defined from nat1.xml
可以通过net-list查看
1 2 3 4 5
[cshrimp-a300 ~]# virsh net-list --all Name State Autostart Persistent ---------------------------------------------- default inactive no yes nat1 inactive no yes
启动和自启网络
启动方法如下
1
virsh net-start nat1
设置自启动
1
virsh net-autostart nat1
查看反馈
1 2 3 4 5 6 7 8 9 10
[cshrimp-a300 ~]# virsh net-list Name State Autostart Persistent ----------------------------------------- nat1 active yes yes
[cshrimp-a300 ~]# ip a s virbr1 20: virbr1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:e3:31:51 brd ff:ff:ff:ff:ff:ff inet 172.20.20.1/24 brd 172.20.20.255 scope global virbr1 valid_lft forever preferred_lft forever
[cshrimp-a300 ~]# virsh net-dhcp-leases nat1 Expiry Time MAC address Protocol IP address Hostname Client ID or DUID ---------------------------------------------------------------------------------------------------------- 2024-08-08 19:09:43 52:54:00:26:06:35 ipv4 172.20.20.105/24 - 01:52:54:00:26:06:35
[root@localhost ~]# ip a s eth1 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 52:54:00:26:06:35 brd ff:ff:ff:ff:ff:ff altname enp7s0 inet 172.20.20.105/24 brd 172.20.20.255 scope global dynamic noprefixroute eth1 valid_lft 3058sec preferred_lft 3058sec inet6 fe80::f409:13e5:80ef:5d6b/64 scope link noprefixroute valid_lft forever preferred_lft forever [root@localhost ~]# ip route default via 172.20.20.1 dev eth1 proto dhcp src 172.20.20.105 metric 101 172.20.20.0/24 dev eth1 proto kernel scope link src 172.20.20.105 metric 101 [root@localhost ~]# ping 172.20.20.1 -c 2 PING 172.20.20.1 (172.20.20.1) 56(84) bytes of data. 64 bytes from 172.20.20.1: icmp_seq=1 ttl=64 time=0.234 ms 64 bytes from 172.20.20.1: icmp_seq=2 ttl=64 time=0.289 ms
--- 172.20.20.1 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1038ms rtt min/avg/max/mdev = 0.234/0.261/0.289/0.027 ms [root@localhost ~]# ping 223.5.5.5 -c 2 PING 223.5.5.5 (223.5.5.5) 56(84) bytes of data. 64 bytes from 223.5.5.5: icmp_seq=1 ttl=115 time=41.1 ms 64 bytes from 223.5.5.5: icmp_seq=2 ttl=115 time=40.7 ms
--- 223.5.5.5 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 40.726/40.924/41.122/0.198 ms [root@localhost ~]# ping huawei.com -c 2 PING huawei.com (121.37.49.12) 56(84) bytes of data. 64 bytes from ecs-121-37-49-12.compute.hwclouds-dns.com (121.37.49.12): icmp_seq=1 ttl=50 time=7.24 ms 64 bytes from ecs-121-37-49-12.compute.hwclouds-dns.com (121.37.49.12): icmp_seq=2 ttl=50 time=6.92 ms
--- huawei.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 6.924/7.081/7.239/0.157 ms