linux系统添加网卡设备及搭建阿里yum源

  • 网卡的使用
    [root@cobbler cobbler]# nmcli connection add type ethernet con-name eth1 ifname eth1
    连接“eth1”(9647a0f6-b44d-4a2d-b420-984e61352c30) 已成功添加。 #添加网卡eth1
    [root@cobbler cobbler]# nmcli connection delete eth1 # 删除网卡
    成功删除连接 ‘eth1’(9647a0f6-b44d-4a2d-b420-984e61352c30)。

[root@cobbler cobbler]# nmcli connection down eth0 #关闭网卡
成功取消激活连接 ‘eth0’(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/5)
[root@cobbler cobbler]# nmcli connection up eth0 #激活网卡
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/6)

https://opsx.alibaba.com/mirror?lang=zh-CN #阿里yum源网站

  • 搭建阿里yum源,虚拟机要桥接网卡配置网关,ping通外网

linux系统添加网卡设备及搭建阿里yum源_第1张图片
[root@cobbler yum.repos.d]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 #配置网卡配置文件
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=eth0
UUID=87a6296a-71fa-4e21-be37-dc9d2b7c858c
DEVICE=eth0
ONBOOT=yes
IPADDR=176.130.7.12
PREFIX=24
GATEWAY=176.130.7.1 #添加网关

[root@cobbler ~]# systemctl restart network #重起网卡服务

[root@cobbler ~]# route -n #查看网关
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 176.130.7.1 0.0.0.0 UG 100 0 0 eth0
176.130.7.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
[root@cobbler ~]# ping qq.com #ping外网qq.com
PING qq.com (59.37.96.63) 56(84) bytes of data.
64 bytes from 59.37.96.63 (59.37.96.63): icmp_seq=1 ttl=55 time=59.6 ms
64 bytes from 59.37.96.63 (59.37.96.63): icmp_seq=2 ttl=55 time=28.4 ms

[root@cobbler yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo #下载阿里yum源配置文件

  • yum 相关命令
    [root@cobbler ~]# yum clean all #清空 yum 缓存
    [root@cobbler ~]# yum list #生成缓存列表
    [root@lias yum.repos.d]# yum install -y httpd #安装验证
    [root@cobbler ~]# yum -y reinstall httpd #强制重装
    [root@cobbler ~]# yum -y remove http #卸载软件
    [root@cobbler ~]# yum repolist #列仓库

你可能感兴趣的:(yum,linux,linux)