Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure dual network card, dual IP and dual gateway on the server

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to configure dual network cards and double IP gateways on the server, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let's take a look at it.

Configuration details

Configure DNS

Modify the configuration file of the DNS of the corresponding network card

# vi / etc/resolv.conf

You can set more than one by modifying the following:

Nameserver 202.106.0.20 nameserver 114.114.114.114 nameserver 8.8.8.8

Configure the gateway of the public network card to modify the configuration file of the gateway

[root@centos] # vim / etc/sysconfig/network modifies the following content NETWORKING=yes (indicates whether the system uses a network, which is generally set to yes. If set to no, the network cannot be used, and many system service programs will not be able to start) HOSTNAME=centos (set the hostname of this machine, which corresponds to the hostname set in / etc/hosts) GATEWAY=192.168.1.1 (Note: it needs to be configured as the gateway of the public network card)

Configure IP addr

Modify the configuration file of the IP address of the corresponding network card

# vi / etc/sysconfig/network-scripts/ifcfg-eth0

Modify the following

DEVICE=eth0 # describes the device alias corresponding to the network card. For example, in the file of ifcfg-eth0, it is generally used for the eth0,Dell server: em1 and em2 BOOTPROTO=static # set the way for the network card to obtain the ip address. The possible options are static,dhcp or bootp, corresponding to the statically specified ip address, and the ip address obtained through the dhcp protocol. The ip address BROADCAST=192.168.0.255 # obtained through the bootp protocol corresponds to the subnet broadcast address HWADDR=00:07:E9:05:E8:B4 # the physical address of the network card IPADDR=12.168.1.2 # if you set the network card to obtain the ip address statically, this field specifies the ip address corresponding to the network card GATEWAY= # Note: the gateway must be entered for the external network card, but the internal network card must be empty. Otherwise, if both network cards are enabled at the same time, the network address corresponding to the network mask NETWORK=192.168.1.0 # network card of the external network IPV6INIT=no IPV6_AUTOCONF=no NETMASK=255.255.255.0 # network card will not be enabled. ONBOOT=yes # whether this network interface will be set when the system starts. If it is set to yes, the device will be activated when the system starts.

Note: in the configuration file corresponding to the IP address of the Nic, if the configuration is the configuration file corresponding to the Nic of the public network, then GATEWAY must be entered. If the configuration is the configuration file of the Nic of the private network, GATEWAY must be empty or comment out this item.

Restart the network configuration

# service network restart or # / etc/init.d/network restart

Configuration of actual combat

System and IP Settings

OS:CentOS version 6.8.

IP1:10.3.3.34 / Gateway: 10.3.3.1 / MASK: 255.255.255.0

IP2:10.2.2.95 / Gateway: 10.2.2.1 / MASK: 255.255.255.0

Use the ifconfig command to view the specific information as follows:

[root@v1 ~] # ifconfig eth0 Link encap:Ethernet HWaddr 00:15:5D:02:16:00 inet addr:10.3.3.34 Bcast:10.3.3.255 Mask:255.255.255.0 inet6 addr: fe80::215:5dff:fe02:1600/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:91723 errors:0 dropped:0 overruns:0 frame:0 TX packets:48020 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:63371661 (60.4 MiB) TX bytes:5979057 (5.7 MiB) eth2 Link encap:Ethernet HWaddr 00:15:5D:02:16:15 inet addr:10.2.2.95 Bcast:10.2.2.255 Mask:255.255.255.0 inet6 addr: Fe80::215:5dff:fe02:1615/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:570504 errors:0 dropped:0 overruns:0 frame:0 TX packets:2849 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:97709676 (93.1 MiB) TX bytes:603377 (589.2 KiB) lo Link encap:Local Loopback Inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: 1Comp128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:148 errors:0 dropped:0 overruns:0 frame:0 TX packets:148 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:12832 (12. 5 KiB) TX bytes:12832 (12.5 KiB)

Here, we define the 10.2.2.0 network segment as the public network and the 10.3.3.0 network segment as the internal network.

Configure DNS

Modify the configuration file of the DNS of the corresponding network card

# vi / etc/resolv.conf

You can set more than one by modifying the following:

Nameserver 202.106.0.20 nameserver 114.114.114.114 nameserver 8.8.8.8

Configure the gateway of the public network card to modify the configuration file of the gateway

[root@centos] # vi / etc/sysconfig/network NETWORKING=yes HOSTNAME=centos NTPSERVERARGS=iburst GATEWAY=10.2.2.1

Configure IP addr

Configure the IP address corresponding to the private network

# vi / etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 TYPE=Ethernet UUID=796d2afc-01ca-4a35-830e-25f9a8f024f3 ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static IPADDR=10.3.3.34 BROADCAST=10.3.3.255 NETMASK=255.255.255.0 # GATEWAY=10.3.3.1 HWADDR=00:15:5D:02:16:00 DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME= "System eth0" DNS1=8.8.8.8

Note: when configuring the intranet, the GATEWAY item is commented out.

# vi / etc/sysconfig/network-scripts/ifcfg-eth2 DEVICE=eth2 TYPE=Ethernet UUID=7696cebd-7c30-454a-88a8-473275511dde ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static IPADDR=10.2.2.95 GATEWAY=10.2.2.1 BROADCAST=10.2.2.255 NETMASK=255.255.255.0 NETWORK=10.2.2.0 HWADDR=00:15:5D:02:16:15 DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME= "System eth2" DNS1=8.8.8.8

Note: for the configuration of public network, GATEWAY must be configured.

Restart the network configuration

# service network restart or # / etc/init.d/network restart Thank you for reading this article carefully. I hope the article "how to configure dual network cards and dual IP gateways on the server" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report