目录
一、配置NAT网络
1.1NAT网络的原理
1.2通过图形界面来配置NAT网络
一、配置NAT网络
1.1NAT网络的原理
虚拟机的NAT地址转换功能通过虚拟化软件创建的虚拟网络接口,将虚拟机私有地址转换为主机公共IP地址,并记录转换信息,实现与外部网络的通信。
NAT地址转换功能使多个虚拟机共享主机的公共IP地址,实现网络连接的共享和隔离。
1.2通过图形界面来配置NAT网络
虚拟机启动网络服务后,虚拟机使用的网卡enpls0顺利获得IP地址。
[root@localhost zhou]# ip addr1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft foreverinet6 ::1/128 scope hostvalid_lft forever preferred_lft forever2: enp1s0: mtu 1500 qdisc fq_codel state UP group default qlen 1000 #虚拟机网卡link/ether 52:54:00:97:8f:58 brd ff:ff:ff:ff:ff:ffinet 192.168.100.155/24 brd 192.168.100.255 scope global dynamic noprefixroute enp1s0 valid_lft 3592sec preferred_lft 3592secinet6 fe80::80ae:62b3:e297:1c24/64 scope link noprefixroutevalid_lft forever preferred_lft forever3: virbr0: mtu 1500 qdisc noqueue state DOWN group default qlen 1000link/ether 52:54:00:c7:1d:8d brd ff:ff:ff:ff:ff:ffinet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever4: virbr0-nic: mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000link/ether 52:54:00:c7:1d:8d brd ff:ff:ff:ff:ff:ff[root@localhost zhou]#
此时虚拟机与外网连通。
[root@localhost zhou]# ping -c 4 baidu.comPING baidu.com (110.242.68.66) 56(84) bytes of data.64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=1 ttl=127 time=50.0 ms64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=2 ttl=127 time=50.1 ms64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=3 ttl=127 time=46.4 ms64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=4 ttl=127 time=89.9 ms--- baidu.com ping statistics ---4 packets transmitted, 4 received, 0% packet loss, time 9msrtt min/avg/max/mdev = 46.406/59.117/89.917/17.846 ms