Linux Dual network card single Gateway setting method

Source: Internet
Author: User
Tags flush

Want to test the cache server to run 2G of traffic to see. Try to let your IP scheduler to the server on the original basis, add 20% weights, so the request will be more on the original base of more than 20% of the amount. Originally the whole machine is basically floating in 800m-900m. So you have to use another network card to run, do not want to bind. This time, because of the new regulation, it has been monitoring its performance.

It's obvious that the back is getting bigger and higher than the previous average of 17%. Found a noticeable drop in performance.

My original server environment:

Nic One (eth0) ip:112.253.xx.45 gateway address: 112.253.xx.5 network card Two (ETH1) ip:112.253.xx.160 gateway address: 112.253.xx.5

Then go up and use iftop to see that all the traffic is running in the default network card. So the flow of exports has not changed, at most so much. Can only call the two lines by the technology, that mouth incoming traffic. Returned by the incoming port, which is called the original route return routing function. Add two routing table information First: Net_eth0 and Net_eth1, respectively.

$ vim/etc/iproute2/rt_tables 252 Net_eth0 251 Net_eth1

Then use the following command. To configure the two routing table information and write to the rc.local

IP route flush Table net_eth0 IP route add default via 112.253.xx.5 dev eth0 src 112.253.xx.45 table net_eth0 IP rule add From 112.253.xx.45 table net_eth0 IP route flush Table net_eth1 IP route add default via 112.253.xx.5 dev eth1 src 112.253 . xx.160 Table net_eth1 IP rule add from 112.253.xx.5 table Net_eth1

The above means setting the default routing gateway and IP on the two NIC interfaces. Because I am the same segment so the gateway is the same. If you want to do telecom netcom two lines to distinguish the user request, it is necessary to set them into telecom netcom two gateways. Then set what source through these two routing tables.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.