网络配置RHCE-Day6

网络参数


计算机名称
IP地址
子网掩码
默认网关
DNS服务器地址

1、计算机名称


# hostname
localhost.localdomain


# uname -n
localhost.localdomain


修改计算机名称
# hostnamectl set-hostname test.bj.com


# vim /etc/hostname 




查看网卡信息


查看IP信息
# ifconfig
# ip addr show 
# nmcli connection show eno16777728 
# nmcli device show eno16777728 


查看网关
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.1.1.0        0.0.0.0         255.255.255.0   U     0      0        0 eno16777728


查看DNS服务器地址
# cat /etc/resolv.conf 
# Generated by NetworkManager
search bj.com
nameserver 114.114.114.114




配置TCP/IP参数 


编辑网卡配置文件


存放路径:/etc/sysconfig/network-scripts/ifcfg-<网卡名称>

# vim /etc/sysconfig/network-scripts/ifcfg-eno16777728 
TYPE=Ethernet
BOOTPROTO=static
ONBOOT=yes
IPADDR0=10.1.1.22
NETMASK0=255.255.255.0
GATEWAY0=10.1.1.254


DNS1=114.114.114.114
DNS2=8.8.8.8


重启网络服务
# systemctl restart network



nmcli 


1、创建网卡配置文件
# nmcli connection add type ethernet ifname <网卡名称> con-name <配置文件>


指定网卡获取IP的方式为手动配置
# nmcli connection modify <配置文件> ipv4.method manual


2、配置TCP/IP参数 
# nmcli connection modify <配置文件> [+]ipv4.addresses "192.168.1.1/24 192.168.1.254"
# nmcli connection modify <配置文件> [+]ipv4.dns "114.114.114.114"


 




rhel 7.2:
# nmcli connection modify <配置文件> ipv4.address "192.168.1.1/24"
# nmcli connection modify <配置文件> ipv4.gateway "192.168.1.1"


3、禁用网卡连接
# nmcli connection down <配置文件>


4、启用网卡
# nmcli connection up <配置文件>


5、删除网卡配置文件
# nmcli connection delete <配置文件>




####以下命令可以执行
nmcli connection add type ethernet ifname eno16777736 con-name test
nmcli connection modify test ipv4.method manual ipv4.addresses "192.168.1.1/24 192.168.1.254"
nmcli connection modify test ipv4.method manual ipv4.dns "114.114.114.114"
nmcli connection up test




网卡聚合 
作用:避免网卡单点故障

工作模式(7种):
loadbalance 负载均衡
activebackup 主备
roundrobin
broadcast
lacp

1、创建虚拟网卡
# nmcli connection add type team ifname <网卡名称> con-name <配置文件> config <工作模式>

工作模式:
'{"runner":{"name":"loadbalance"}}'


2、配置虚拟网卡的IP参数
3、将物理网卡与虚拟网卡绑定
# nmcli connection add type team-slave ifname <网卡名称> con-name <配置文件>
master <虚拟网卡名称>


创建虚拟网卡team1,指定其工作在负载均衡模式,并为其配置如下网络参数
IP:172.16.1.1/24    GW: 172.16.1.254 
DNS:114.114.114.114 DNS2:8.8.8.8 
添加两块网卡
# nmcli connection add type team ifname team1 con-name team1 config '{"runner":{"name":"loadbalance"}}'


# nmcli connection modify team1 ipv4.addresses "172.16.1.1/24 172.16.1.254"    


(/24为子网掩码,255.255.255.0)




# nmcli connection modify team1 ipv4.dns "114.114.114.114"
# nmcli connection modify team1 +ipv4.dns "8.8.8.8"
# nmcli connection modify team1 ipv4.method manual

# nmcli connection add type team-slave ifname eno50332184 con-name team1-eno50332184 master team1 
# nmcli connection add type team-slave ifname eno67109408 con-name team1-eno67109408 master team1


查看team1的状态 
# teamdctl team1 state
setup:
  runner: loadbalance
ports:
  eno50332184
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
  eno67109408
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up



# 刷新配置,以便生效
nmcli connection up inet_name
nmcli connection dowm team1-eno50332184





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值