您的位置:首页 > 运维架构 > Linux

Linux多网卡多IP配置记录

2018-04-16 01:52 537 查看
腾讯云的机器,加了一块弹性网卡,记录下配置:

配置文件目录

cd /etc/sysconfig/network-scripts/

主网卡配置

cat ifcfg-eth0

# Created by cloud-init on instance boot automatically, do not edit.
#
BOOTPROTO=none
DEFROUTE=yes
DEVICE=eth0
GATEWAY=172.16.0.1
HWADDR=52:54:00:48:4b:1c
IPADDR=172.16.0.8
NETMASK=255.255.240.0
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
USERCTL=no

副网卡配置

cat ifcfg-eth1

# edited by Luke.
#
BOOTPROTO=static
# DEFROUTE=yes
DEVICE=eth1
GATEWAY=172.16.0.1
# HWADDR=52:54:00:48:4b:1c
IPADDR=172.16.0.16
NETMASK=255.255.240.0
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
#USERCTL=no

关闭 rp_filter 校验

vim /etc/sysctl.conf

net.ipv4.conf.default.rp_filter = 1

修改成:

net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.eth0.rp_filter = 0
net.ipv4.conf.eth1.rp_filter = 0

其他IP配置

cat ifcfg-eth0:0

BOOTPROTO=static
DEVICE=eth0:0
IPADDR=172.16.0.10
NETMASK=255.255.240.0
ONBOOT=yes

重启网络&测试

systemctl restart network

ip addr

curl --interface eth0 ip.sb

curl --interface eth1 ip.sb

curl --interface eth0:0 ip.sb

curl --interface eth0:1 ip.sb
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: