栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

RHCSA---第六天

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

RHCSA---第六天

网络管理

三种网络模式

仅主机: 虚拟机都为仅主机模式,多台虚拟可以互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=Ethernet
PROXY_METHOD=none
BROWSER_onLY=no
BOOTPROTO=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=yes
DNS1=114.114.114.114
IPV6_PRIVACY=no
IPADDR=192.168.220.111
PREFIX=24
GATEWAY=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, proxy
nmcli>                          tab
activate  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-timeout
nmcli 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]: yes
nmcli ipv4> save
Error: connection verification failed: ipv4.gateway: gateway cannot be set if there are no addresses configured
You may try running 'verify fix' to fix errors.
nmcli ipv4> remove 
addresses           dhcp-send-hostname  dns-search          method              routing-rules
dad-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.dns
nmcli ipv4> save
Connection '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=Ethernet
PROXY_METHOD=none
BROWSER_onLY=no
BOOTPROTO=dhcp
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=yes
IPV6_PRIVACY=no
[root@162 ~]# nmcli connection add type ethernet ifname ens160 con-name work
Connection 'work' (dcab47ad-1250-458f-ad64-7471f4bb41e0) successfully added.
[root@162 ~]# vim /etc/sysconfig/network-scripts/ifcfg-work 
​
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_onLY=no
BOOTPROTO=dhcp
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=work
UUID=dcab47ad-1250-458f-ad64-7471f4bb41e0
DEVICE=ens160
onBOOT=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 work
root@162 ~]# nmcli connection delete work
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/741566.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号