标题:
CentOS7_配置双网卡
[打印本页]
作者:
admin
时间:
2020-5-19 16:05
标题:
CentOS7_配置双网卡
操心系统的版本信息: [root@ser1 ~]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
[root@ser1 ~]# [root@ser1 ~]# uname -r 3.10.0-1127.el7.x86_64 添加网卡后,重启network服务: [root@ser1 ~]# systemctl restart network 先查看可用的网卡名: [root@ser1 ~]# yum -y install net-tools [root@ser1 ~]# [root@ser1 ~]#
ifconfig -a
ens33
: flags=4163
mtu 1500 inet 192.168.168.190 netmask 255.255.255.0 broadcast 192.168.168.255 inet6 fe80::cdfe:bc9c:e597:3afb prefixlen 64 scopeid 0x20
ether 00:0c:29:4d:2e:62 txqueuelen 1000 (Ethernet) RX packets 669 bytes 53683 (52.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 425 bytes 58645 (57.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens38
: flags=4163
mtu 1500 inet 192.168.60.134 netmask 255.255.255.0 broadcast 192.168.60.255 inet6 fe80::a7c8:1961:ac6a:1f1 prefixlen 64 scopeid 0x20
ether 00:0c:29:f3:64:1e txqueuelen 1000 (Ethernet) RX packets 20 bytes 2333 (2.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 21 bytes 2252 (2.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73
mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 新网卡(
ens38)
可以立刻检测出来,但要创建配置文件: [root@ser1 ~]# cd /etc/sysconfig/network-scripts/ [root@ser1 network-scripts]# ls ifcfg-*
ifcfg-ens33
ifcfg-lo [root@ser1 network-scripts]# [root@ser1 network-scripts]# cp ifcfg-ens33 ifcfg-ens38 [root@ser1 network-scripts]# [root@ser1 network-scripts]# ls ifcfg-* ifcfg-ens33
ifcfg-ens38
ifcfg-lo 原网卡(
ens33
)的配置文件: [root@ser1 network-scripts]# cat
ifcfg-ens33
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="
ens33
" UUID="ea21fb8e-76e0-4a44-9e13-ffa9b1bacdb3" DEVICE="
ens33
" ONBOOT="yes" IPADDR="
192.168.168.190
" PREFIX="24" GATEWAY="192.168.168.2" DNS1="8.8.8.8" DNS2="114.114.114.114" IPV6_PRIVACY="no" 修改新网卡(
ens38
)的配置文件: [root@ser1 network-scripts]# cat
ifcfg-ens38
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="
ens38
" DEVICE="
ens38
" ONBOOT="yes" IPADDR="
192.168.169.191
" PREFIX="24" IPV6_PRIVACY="no" 笺注: 文件里的ens33要改为
ens38
; UUID那行要删除; 新网卡不用配置网关和DNS地址; 两张网卡理应使用不同的IP网段; 重启network服务: [root@ser1 ~]# systemctl restart network 查看所有网卡的IP地址: [root@ser1 ~]# ifconfig
ens33
: flags=4163
mtu 1500 inet
192.168.168.190
netmask 255.255.255.0 broadcast 192.168.168.255 inet6 fe80::cdfe:bc9c:e597:3afb prefixlen 64 scopeid 0x20
ether 00:0c:29:4d:2e:62 txqueuelen 1000 (Ethernet) RX packets 1371 bytes 109307 (106.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 789 bytes 104083 (101.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens38
: flags=4163
mtu 1500 inet
192.168.169.191
netmask 255.255.255.0 broadcast 192.168.169.255 inet6 fe80::5002:bd18:de7:18f3 prefixlen 64 scopeid 0x20
ether 00:0c:29:f3:64:1e txqueuelen 1000 (Ethernet) RX packets 107 bytes 9946 (9.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 39 bytes 3896 (3.8 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73
mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 至此,服务器既可以连接公网,也可以跟不同IP网段的主机进行通讯了: [root@ser1 ~]# ping -c3
www.baidu.com
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data. 64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=1 ttl=128 time=1094 ms 64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=2 ttl=128 time=91.0 ms 64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=3 ttl=128 time=69.3 ms --- www.a.shifen.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2022ms rtt min/avg/max/mdev = 69.374/418.477/1094.982/478.443 ms, pipe 2 [root@ser1 ~]# ping -c3
192.168.168.135
PING 192.168.168.135 (192.168.168.135) 56(84) bytes of data. 64 bytes from 192.168.168.135: icmp_seq=1 ttl=64 time=1.12 ms 64 bytes from 192.168.168.135: icmp_seq=2 ttl=64 time=0.784 ms 64 bytes from 192.168.168.135: icmp_seq=3 ttl=64 time=1.00 ms --- 192.168.168.135 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2012ms rtt min/avg/max/mdev = 0.784/0.968/1.120/0.139 ms [root@ser1 ~]# ping -c3
192.168.169.136
PING 192.168.169.136 (192.168.169.136) 56(84) bytes of data. 64 bytes from 192.168.169.136: icmp_seq=1 ttl=128 time=1.75 ms 64 bytes from 192.168.169.136: icmp_seq=2 ttl=128 time=1.69 ms 64 bytes from 192.168.169.136: icmp_seq=3 ttl=128 time=1.11 ms --- 192.168.169.136 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2028ms rtt min/avg/max/mdev = 1.114/1.520/1.753/0.288 ms 相关文章:
最小化安装CentOS7.8
CentOS6_配置双网卡
欢迎光临 blog.zhuohua.store (http://blog.zhuohua.store/)
Powered by Discuz! 7.2