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 route network card alias in CentOS dual network card internal and external network

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the CentOS dual network card internal and external network how to configure route network card alias, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Dual Nic configuration: add a Nic to the virtual machine settings in host-only mode, generate a new MAC address in / etc/udev/rules.d/70-persistent-net.rule after restart, copy the Nic eth0 to eth2, remove UUID and modify the correct MAC address, and modify the configuration file:

BOOTPROTO= {static | none | dhcp | bootp}: to use a static address, use static or none;dhcp to obtain the address using the DHCP server

IPADDR=: IP address NETMASK=: subnet mask GATEWAY=: sets the default gateway; only one gateway can be set for two network cards. The gateway is the gateway in the virtual machine-network editor. If you need to access the Internet, you need to add a DNS1= gateway to the public network eth0. Restart the network card service and you can surf the Internet normally.

Network configuration:

Network profile: / etc/sysconfig/network

Network interface profile: ifcfg-ethx

/ etc/sysconfig/network-scripts/ifcfg-ethx

The device name associated with DEVICE=:, which should be consistent with the second half of the file name "ethx"

BOOTPROTO= {static | none | dhcp | bootp}: boot protocol; to use a static address, use static or none;dhcp to obtain the address using a DHCP server

IPADDR=: IP address

NETMASK=: subnet mask

GATEWAY=: sets the default gateway

Whether this network interface is automatically activated when ONBOOT=: is powered on

HWADDR=: hardware address, which should be consistent with the address in the hardware; save

The modification will not take effect immediately, but the restart of the network service or host will take effect.

Add routes:

Route: / etc/sysconfig/network-scripts/route-ethX

Add format 1: route-eth2

DEST via NEXTHOP

192.168.10.0 via 10.0.0.254

Add format 2:

ADDRESS0= network address

NETMASK0= mask

GATEWAY0= Gateway

Add the routing command route:

Route: route add: add [- host: host route,-net: network route, default: default]

Route add-net |-host DEST [iP] gw NEXTHOP [gateway]

Route add default gw NEXTHOP

Del: delete [- host,-net]

Route del-net 10.0.0.0 Compact 8

Route del-net 0.0.0.0

Route del default

[the changes will become invalid after the network service or host is restarted;]

View: route-n: digitally display relevant information such as hosts or ports

There is only one way to specify the DNS server: / etc/resolv.conf

Nameserver DNS_IP_1

Nameserver DNS_IP_2

Specify local resolution: / etc/hosts: host IP hostname host alias [172.16.0.1www.magedu.com www]

Iproute2 command [ifconfig obsolete]

Link: network interface attributes, addr: protocol address, route: routing

Link show [ip-slink show eth0] is equivalent to ifconfig eth0

Set [ip link set DEV {up | down}] starts the network card

Addr add [ip addr add ADDRESSdev DEV] add IP to network card device DEV

Del [ip addr del ADDRESSdev DEV] Delete the protocol address

Show [ip addr show dev DEV to PREFIX [specify prefix]]

Flush [ip addr flush dev DEV [eth0] to PREFIX] clears the protocol address

Nic configuration alias:

Network devices can be aliased: ethX:X, eth0:0, eth0:1,...

Configuration method: ifconfig ethX:X IP/NETMASK [Subnet Mask]

/ etc/sysconfig/network-scripts/ifcfg-ethX:X

DEVICE=ethX:X [non-primary addresses cannot be dynamically learned using DHCP]

Ip eth2, add an address of 192.168.100.1

Ip addr add 192.168.100.1 ip addr add 24 dev eth2 labeleth2:0 [alias ipconfig display, view ip addr show]

Ifconfigeth0:0 192.168.50.1 netmask 255.255.255.255 broadcast 192.168.50.1 [alias full configuration]

Thank you for reading this article carefully. I hope the article "how to configure route network card aliases in and out of CentOS dual network cards" shared by the editor will be helpful to everyone. At the same time, I also hope that 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