欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

RHCSA---第六天

时间:2023-05-16
网络管理

三种网络模式

仅主机: 虚拟机都为仅主机模式,多台虚拟可以互ping; 物理机 --ping ---->虚拟机

nat: 虚拟机都为nat模式,多台虚拟可以互ping; 物理机 <-----ping ---->虚拟机 只要物理能访问外网虚拟机就能上网

桥接: 虚拟机都为桥接模式,多台虚拟可以互ping;物理机 <-----ping ---->虚拟机 (同一网段的地址);可以访问外网(当前主机的地址能不能访问外网)

网卡动态和静态地址配置

1.虚拟图形界面

2.nmtui 连接图形化界面进行配置(键盘)

3.nm-connection-editor 鼠标控制

4.网卡配置文件

[root@162 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens160 TYPE=Ethernet 网卡类型 Ethernet真实网卡 PROXY_METHOD=none BROWSER_onLY=no BOOTPROTO=dhcp 网卡模式dhcp动态模式 none 静态模式 DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens160 网卡配置文件名 UUID=29a02f09-4754-4f2f-a91b-b0fd3cbf7987 DEVICE=ens160 网卡设备名 onBOOT=no 网卡开机后是否自动连接 IPV6_PRIVACY=no

注:RHEL7- 一个网卡设备可以对应多个网卡配置文件,但是当前网卡默认只能连接一个网卡配置

*5.nmcli 网络管理工具

nmcli device show 显示主机所有网络设备详细信息

status 显示主机设备和会话(网卡配置文件)

connect 将设备和指定会话文件链接

nmcli connection show

modify

edit

add

delete

up

down

nmcli配置静态ip地址​[root@162 ~]# nmcli connection modify ens160 ipv4.method manual ipv4.addresses 192.168.220.111/24 ipv4.dns 114.114.114.114 ipv4.gateway 192.168.220.2 connection.autoconnect yes    --修改ens160会话文件参数   网络模式=manual ipv4.地址=   connection.autoconnect yes 设置网卡开机自动连接[root@162 ~]# nmcli connection up ens160         ---激活ens160网卡配置​[root@162 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens160 TYPE=EthernetPROXY_METHOD=noneBROWSER_onLY=noBOOTPROTO=noneDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_FAILURE_FATAL=noIPV6_ADDR_GEN_MODE=stable-privacyNAME=ens160UUID=29a02f09-4754-4f2f-a91b-b0fd3cbf7987DEVICE=ens160onBOOT=yesDNS1=114.114.114.114IPV6_PRIVACY=noIPADDR=192.168.220.111PREFIX=24GATEWAY=192.168.220.2

[root@162 ~]# nmcli connection edit ens160     --进入编辑网卡配置文件​===| nmcli interactive connection editor |===​Editing existing '802-3-ethernet' connection: 'ens160'​Type 'help' or '?' for available commands.Type 'print' to show all the connection properties.Type 'describe [. ]' for detailed property description.​You may edit the following settings: connection, 802-3-ethernet (ethernet), 802-1x, dcb, sriov, ethtool, match, ipv4, ipv6, tc, proxynmcli>                         tabactivate describe help     print     remove   set       back     goto     nmcli     quit     save     verify    nmcli> goto ipv4               进入iPv4模式You may edit the following properties: method, dns, dns-search, dns-options, dns-priority, addresses, gateway, routes, route-metric, route-table, routing-rules, ignore-auto-routes, ignore-auto-dns, dhcp-client-id, dhcp-timeout, dhcp-send-hostname, dhcp-hostname, dhcp-fqdn, never-default, may-fail, dad-timeoutnmcli ipv4> activate describe help     print     remove   set       back     goto     nmcli     quit     save     verify    nmcli ipv4> set method auto       disabled   link-local manual     shared      nmcli ipv4> set method auto   将网络模式改为自动模式Do you also want to clear 'ipv4.addresses'? [yes]: yesnmcli ipv4> saveError: connection verification failed: ipv4.gateway: gateway cannot be set if there are no addresses configuredYou may try running 'verify fix' to fix errors.nmcli ipv4> remove addresses           dhcp-send-hostname dns-search         method             routing-rulesdad-timeout         dhcp-timeout       gateway             never-default       dhcp-client-id     dns                 ignore-auto-dns     route-metric        dhcp-fqdn           dns-options         ignore-auto-routes routes              dhcp-hostname       dns-priority       may-fail           route-table         nmcli ipv4> remove ipv4.gateway  nmcli ipv4> remove ipv4.dnsnmcli ipv4> saveConnection 'ens160' (29a02f09-4754-4f2f-a91b-b0fd3cbf7987) successfully updated.nmcli ipv4> quit[root@162 ~]# nmcli connection up ens160 ​[root@162 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens160 TYPE=EthernetPROXY_METHOD=noneBROWSER_onLY=noBOOTPROTO=dhcpDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_FAILURE_FATAL=noIPV6_ADDR_GEN_MODE=stable-privacyNAME=ens160UUID=29a02f09-4754-4f2f-a91b-b0fd3cbf7987DEVICE=ens160onBOOT=yesIPV6_PRIVACY=no

[root@162 ~]# nmcli connection add type ethernet ifname ens160 con-name workConnection 'work' (dcab47ad-1250-458f-ad64-7471f4bb41e0) successfully added.[root@162 ~]# vim /etc/sysconfig/network-scripts/ifcfg-work ​TYPE=EthernetPROXY_METHOD=noneBROWSER_onLY=noBOOTPROTO=dhcpDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_FAILURE_FATAL=noIPV6_ADDR_GEN_MODE=stable-privacyNAME=workUUID=dcab47ad-1250-458f-ad64-7471f4bb41e0DEVICE=ens160onBOOT=yes[root@162 ~]# nmcli connection modify work ipv4.method manual ipv4.addresses 192.168.220.111/24 ipv4.dns 114.114.114.114 ipv4.gateway 192.168.220.2 [root@162 ~]# nmcli connection up workroot@162 ~]# nmcli connection delete work

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。