John_ABC

资讯 2024-06-20 阅读:24 评论:0
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

eth0 eth0:1 和eth0.1三者的关系对应于物理网卡、子网卡、虚拟VLAN网卡的关系:
物理网卡:物理网卡这里指的是服务器上实际的网络接口设备,这里我服务器上双网卡,在系统中看到的2个物理网卡分别对应是eth0和eth1这两个网络接口。
 
子网卡:子网卡在这里并不是实际上的网络接口设备,但是可以作为网络接口在系统中出现,如eth0:1、eth1:2这种网络接口。它们必须要依赖于物理网卡,虽然可以与物理网卡的网络接口同时在系统中存在并使用不同的IP地址,而且也拥有它们自己的网络接口配置文件。但是当所依赖的物理网卡不启用时(Down状态)这些子网卡也将一同不能工作。
 
虚拟VLAN网卡:这些虚拟VLAN网卡也不是实际上的网络接口设备,也可以作为网络接口在系统中出现,但是与子网卡不同的是,他们没有自己的配置文件。他们只是通过将物理网加入不同的VLAN而生成的VLAN虚拟网卡。如果将一个物理网卡通过vconfig命令添加到多个VLAN当中去的话,就会有多个VLAN虚拟网卡出现,他们的信息以及相关的VLAN信息都是保存在/proc/net/vlan/config这个临时文件中的,而没有独自的配置文件。它们的网络接口名是eth0.1、eth1.2这种名字。

The relationship between eth0 eth0:1 and eth0.1 corresponds to the relationship between physical web cards, subnet cards, virtual VLAN web cards:
physical network cards : The physical network cards refer to the actual network interface devices on the server, where I have two web cards on my server, and the two physical web cards that I see on the system are the two network interfaces for eth0 and eth1.
& nbsp;

注意:当需要启用VLAN虚拟网卡工作的时候,关联的物理网卡网络接口上必须没有IP地址的配置信息,并且,这些主物理网卡的子网卡也必须不能被启用和必须不能有IP地址配置信息。这个在网上看到的结论根据我的实际测试结果来看是不准确的,物理网卡本身可以绑定IP,并且给本征vlan提供通信网关的功能,但必须是在802.1q下。

Note: When a VLAN virtual network card is needed, there must be no configuration of the IP address on the connected physical network interface, and the sub-nets of these main physical network cards must also not be enabled and no IP address configuration information must be available. The conclusion seen online is inaccurate based on my actual test results, and the physical network card itself can bind the IP and provide the communication gateway function for the current sign vlan, but it must be under 802.1q.

 

/sbin/ifconfig 查看、配置、启用或禁用网络接口(网卡)的工具 
ifconfig 是一个用来查看、配置、启用或禁用网络接口的工具,这个工具极为常用的。比如我们可以用这个工具来配置网卡的IP地址、MAC地址、掩码、广播地址等。值得一说的是用ifconfig 为网卡指定IP地址,这只是用来调试网络用的,并不会更改系统关于网卡的配置文件。如果您想把网络接口的IP地址固定下来,目前有三个方法:一是通过各个发行和版本专用的工具来修改IP地址;二是直接修改网络接口的配置文件;三是修改特定的文件,加入ifconfig 指令来指定网卡的IP地址,比如在redhat或Fedora中,把ifconfig 的语名写入/etc/rc.d/rc.local文件中; 

/sbin/ifconfig The tool to view, configure, enable or disable network interfaces (netcards)  
ifconfig is a tool to view, configure, enable or disable network interfaces, which is most commonly used. For example, we can use this tool to configure the IP address of the Internet card, the MAC address, the mask, the broadcast address, etc.. One is to assign IP addresses to the Internet card with ifconfig, which is merely used to debug the network and does not change the system's configuration file on the Internet card. If you want to fix the IP address of the web interface, there are three ways: one is to modify the IP address through a special tool for various distributions and versions; the other is to directly modify the configuration file of the web interface; the third is to modify the IP address of the Internet card by adding the ifconfig command, for example, in redhat or Fedora, to write the ifconfig name to/etc.d/rc.rc.nbsp;

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


ifconfig配置网络接口语法: 
ifconfig 网络端口 IP地址 hw MAC地址 netmask 掩码地址 broadcast 广播地址 [up/down] 

ifconfig常用用法: 


ifconfig configuration network interface syntax:  
ifconfig network port IP address hw MAC address netmask mask address breakcast broadcast address [up/down] 
br>
strang>ifconfig usage:  

  • ifconfig : 查看主机激活状态的网络接口情况; 输出结果中:lo 是表示主机的回坏地址,eth0 表示第一块网卡, 其中 HWaddr 表示网卡的物理地址(MAC地址); inet addr 用来表示网卡的IP地址,Bcast表示广播地址,Mask表示掩码地址
  • ifconfig -a : 查看主机所有(包括没有被激活的)网络接口的情况
  • ifconfig eth0 : 查看特定网络接口的状态
  • ifconfig eth0 down=ifup eth0 : 如果eth0是激活的,就把它终止掉。此命令等同于 ifdown eth0;
  • ifconfig eth0 up=ifdown eth0 : 激活eth0 ; 此命令等同于 ifup eth0 
  • ifconfig eth0 192.168.1.99 broadcast 192.168.1.255 netmask 255.255.255.0 : 配置 eth0的IP地址、广播地址和网络掩码; 
  • ifconfig eth0 192.168.1.99 broadcast 192.168.1.255 netmask 255.255.255.0 up : 配置IP地址、网络掩码、广播地址的同时,激活网卡eth0
  • ifconfig eth1 hw ether 00:11:00:00:11:22 : 设置网卡的物理地址(MAC地址)。其中 hw 后面所接的是网络接口类型, ether表示以太网, 同时也支持 ax25 、ARCnet、netrom等,详情请查看 man ifconfig ; 

 

虚拟IP技术在高可用领域像数据库SQLSERVER、web服务器等场景下使用很多,很疑惑它是怎么实现的,偶然,发现了一种方式可以实现虚拟ip。它的原理在于同一个物理网卡,是可以拥有多个ip地址的,至于虚拟网卡,也可用通过该方式拥有多个ip。  即对外提供数据库服务器的主机除了有一个真实IP外还有一个虚IP,使用这两个IP中的 任意一个都可以连接到这台主机,所有项目中数据库链接一项配置的都是这个虚IP,当服务器发生故障无法对外提供服务时,动态将这个虚IP切换到备用主机

Virtual IP technology is much used in high-availability areas like databases SQLSERVER, web servers, and wonders how it is done, incidentally, to find a way to achieve virtual ip.

其实现原理主要是靠TCP/IP的ARP协议。因为ip地址只是一个逻辑地址,在以太网中MAC地址才是真正用来进行数据传输的物理地址,每台主机中都有一个ARP高速缓存,存储同一个网络内的IP地址与MAC地址的对应关系,以太网中的主机发送数据时会先从这个缓存中查询目标IP对应的MAC地址,会向这个MAC地址发送数据。操作系统会自动维护这个缓存。这就是整个实现 的关键。

The principle of realization is largely based on the TCP/IP ARP protocol. Because the ip address is only a logical address, the MAC address in Ethernet is the physical address that is actually used for data transmission, and each host has an ARP high-speed cache, where the IP address in the same network corresponds to the MAC address, and the MAC address that corresponds to the target IP will be searched by the host in the thernet, and the data will be sent to the MAC address. The operating system will automatically maintain the cache. This is the key to the overall achievement.

在eth0处引用别名,设置完子网掩码即可
ifconfig eth0:0 166.111.69.100 netmask 255.255.255.0 up

Quote aliases at eth0, with a complete net mask at
ifconfig eth0: 016611.169.100 netmask 255.255.255.0 up

此时查看网卡信息

View webcard information at this time

eth0 Link encap:Ethernet HWaddr 08:00:27:64:59:11 
          inet addr:166.111.69.17 Bcast:166.111.69.255 Mask:255.255.255.0
          inet6 addr: 2402:f000:1:4412:a00:27ff:fe64:5911/64 Scope:Global
          inet6 addr: fe80::a00:27ff:fe64:5911/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:597673 errors:0 dropped:0 overruns:0 frame:0
          TX packets:215472 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:67285933 (67.2 MB) TX bytes:22782158 (22.7 MB)

eth0:0 Link encap:Ethernet HWaddr 08:00:27:64:59:11 
          inet addr:166.111.69.100 Bcast:166.111.69.255 Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

lo Link encap:Local Loopback 
          inet addr:127.0.0.1 Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING MTU:16436 Metric:1
          RX packets:843 errors:0 dropped:0 overruns:0 frame:0
          TX packets:843 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:67174 (67.1 KB) TX bytes:67174 (67.1 KB)

然后找另一台机器ping这个vip(eth0:0)就可以看到显示结果了。
写在/etc/rc.local里也可以,写在这里就不怕断电后机器无法正常使用了。

Then find another machine, ping this vip (eth0:0), and you can see the results.
is written in /etc/rc.local, and it is written here that the machine cannot be used properly after the power cuts.

更详细参考:Linux-配置虚拟IP实例

More detailed reference: Linux-configuring virtual IP examples


用ifconfig 来配置虚拟网络接口: 
有时我们为了满足不同的需要还需要配置虚拟网络接口,比如我们用不同的IP地址来架运行多个HTTPD服务器,就要用到虚拟地址;这样就省却了同一个IP地址,如果开设两个的HTTPD服务器时,要指定端口号。 

虚拟网络接口指的是为一个网络接口指定多个IP地址,虚拟接口是这样的 eth0:0 、 eth0:1、eth0:2 ... .. eth1N。当然您为eth1 指定多个IP地址,也就是 eth1:0、eth1:1、eth1:2 ... ...以此类推; 
ifconfig eth1:0 192.168.1.250 hw ether 00:11:00:00:11:44 netmask 255.255.255.0 broadcast 192.168.1.255 up 
ifconfig eth1:1 192.168.1.249 hw ether 00:11:00:00:11:55 netmask 255.255.255.0 broadcast 192.168.1.255 up 
注意:指定时,要为每个虚拟网卡指定不同的物理地址;


Configure virtual network interfaces with ifconfig:  
Sometimes we have to configure virtual network interfaces to meet different needs, such as if we use different IP addresses to run multiple HTTPD servers, using a virtual address; this saves the same IP address; if two HTTPD servers are opened, the port number is assigned. & nbsp;
/br> virtual network interface refers to the designation of multiple IP addresses for a network interface, such as eth0:0, eth0:1,eth0:2.eth:2.

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 0.00003374个比特币等于多少人民币/美金

    0.00003374个比特币等于多少人民币/美金
    0.00003374比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00003374比特币等于2.2826 1222美元/16.5261124728人民币。比特币(BTC)美元(USDT)人民币(CNY)0.00003374克洛克-0/22216.5261124728比特币对人民币的最新汇率为:489807.72 CNY(1比特币=489807.72人民币)(1美元=7.24人民币)(0.00003374USDT=0.0002442776 CNY)。汇率更新于2024...
  • 0.00006694个比特币等于多少人民币/美金

    0.00006694个比特币等于多少人民币/美金
    0.00006694比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00006694比特币等于4.53424784美元/32.5436 16人民币。比特币(BTC)美元(USDT)人民币(CNY)0.000066944.53424784【比特币密码】32.82795436 16比特币对人民币的最新汇率为:490408.64 CNY(1比特币=490408.64人民币)(1美元=7.24人民币)(0.00006694USDT=0.0004846456 CNY)汇率更新时...
  • 0.00015693个比特币等于多少人民币/美金

    0.00015693个比特币等于多少人民币/美金
    0.000 15693比特币等于多少人民币?根据比特币对人民币的最新汇率,0.000 15693比特币等于10.6 1678529美元/76.86554996人民币。比特币(BTC)【比特币价格翻倍】美元(USDT)人民币(CNY)0.000/克洛克-0/5693【数字货币矿机】10.6 167852976.8655254996比特币对人民币的最新汇率为:489,807.72 CNY(1比特币= 489,807.72人民币)(1美元=7.24人民币)(0.00015693 U...
  • 币圈院士:5.20比特币(BTC)以太坊(ETH)行情分析

    币圈院士:5.20比特币(BTC)以太坊(ETH)行情分析
    利空出尽?华尔街多头坚信美股将摆脱泥潭 经济衰退风险被夸大A lot of people on Wall Street believe that beauty will escape the quagmire; the risk of recession is exaggerated. 从目前美国经济的情况加上美股先有的走势来判断,确信通胀已经或即将见顶,这为价格压力回落铺平了道路,这最终将使美联储得以放缓...
  • 2000年美国GDP占世界的304%,中国GDP仅占35%,现在呢?

    2000年美国GDP占世界的304%,中国GDP仅占35%,现在呢?
    GDP作为全球公认的实力基准,就像是一个大国实力的代言人,它是布雷顿森林体系下全球团结的声音。它不仅仅是数字的累积,更是大国综合实力的人格化,默默诉说着每个国家的辉煌与荣耀。虽然GDP不是衡量一个国家综合实力的唯一标准,但无疑是最关键的指标之一。作为一面镜子,它反映了国家的经济实力和发展水平,是国家综合实力的重要体现,不容忽视。2000年,中国GDP迈过/克洛克-0/万亿美元的重要门槛,达到/克洛克-0/。2/克洛克-0/万亿美元(折合人民币7。7万亿元)。然而,在全球经济的...
标签列表