服务器双网卡:
一个内网一个外网,内网与设备交互,外网与第三方服务对接数据。
到网卡配置目录去
cd /etc/sysconfig/network-scripts/
查询网卡编号
ip addr
得到以下数据
[root@192 network-scripts]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:fe:f2:7d brd ff:ff:ff:ff:ff:ff
inet 192.168.85.139/24 brd 192.168.85.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::d6b8:700:daa3:bf44/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:fe:f2:87 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.215/24 brd 192.168.1.255 scope global noprefixroute ens37
valid_lft forever preferred_lft forever
inet6 fe80::9efe:e6db:fbea:7025/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:fe:f2:91 brd ff:ff:ff:ff:ff:ff
5: ens39: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:fe:f2:9b brd ff:ff:ff:ff:ff:ff
编辑网卡(自己确定那个是内网 ,那个是外网)
vi ifcfg-ens33
vi ifcfg-ens37
内容如下:
内网注意,不要配置网关(不要配置网关,不要配置网关,不要配置网关)
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
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=ens224
UUID=cb58fb91-39e3-4e04-ba7c-5b1156e38048
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.85.139
PREFIX=24
IPV6_PRIVACY=no
DNS1=114.114.114.114
外网网卡
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
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=ens192
UUID=26ebe8d1-039b-40c0-ac6b-6295029d4fd6
DEVICE=ens192
ONBOOT=yes
IPADDR=192.168.1.215
PREFIX=24
GATEWAY=192.168.1.1
DNS1=114.114.114.114
IPV6_PRIVACY=no
ZONE=public
修改完了以后,重启网卡服务
service network restart