Linux dual-line server configuration

Source: Internet
Author: User
Article Title: linux dual-line server configuration. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

China Netcom uses the first NIC (eth0 ):
 
IP: 210.82.37.149
 
Mask: always valid
 
Gateway: 210.82.37.158
 
Tietong uses the second NIC (eth1 ):
 
IP: 222.35.92.242
 
Mask: 255.255.255.252
 
Gateway: 222.35.92.241
 
2. Configure the NIC:
 
# Vi/etc/sysconfig/networking/profiles/default/ifcfg-eth0
 
DEVICE = eth0
 
ONBOOT = yes
 
IPADDR = 210.82.37.149
 
NETMASK = zookeeper
 
GATEWAY = 210.82.37.158
 
TYPE = Ethernet
 
# Vi/etc/sysconfig/networking/profiles/default/ifcfg-eth1
 
DEVICE = eth1
 
ONBOOT = yes
 
IPADDR = 222.35.92.242
 
NETMASK = 255.255.255.255.252
 
GATEWAY = 222.35.92.241
 
TYPE = Ethernet
 
# Vi/etc/sysconfig/networking/profiles/default/route-eth1
 
GATEWAY0 = 218.57.200.1
 
NETMASK0 = 255.255.255.0
 
ADDRESS0 = 218.57.200.242
 
# Vi/etc/sysconfig/networking/profiles/default/resolv. conf
 
Nameserver 202.102.152.3
 
Nameserver 202.102.128.68
 
3. Configure the route table
 
# Vi/etc/iproute2/rt_tables: Add two route tables: China Netcom and China tietong
 
252 cnc
 
251 crtc
 
Set the route table of China Netcom
 
Ip route add 210.82.37.128/27 via 210.82.37.149 dev eth0 table cnc
 
Ip route add 127.0.0.0/8 dev lo table cnc
 
Ip route add default via 210.82.37.158 dev eth0 table cnc
 
Set tietong route table
 
Ip route add 222.35.92.240/30 via 222.35.92.242 dev eth1 table crtc
 
Ip route add 127.0.0.0/8 dev lo table crtc
 
Ip route add default via 222.35.92.241 dev eth1 table crtc
 
Formulate a policy to route the response data packet of 222.35.92.242 to the route table of tietong, and route the response data packet of 210.82.37.149 to the route table of Netcom.
 
Ip rule add from 210.82.37.149 table cnc
 
Ip rule add from 222.35.92.242 table crtc
 
Modify IP Forwarding File
 
# Vi/etc/sysctl. conf
 
Net. ipv4.ip _ forward = 1
 
Net. ipv4.conf. default. rp_filter = 1
 
Kernel. sysrq = 0
 
Set static route table File
 
# Vi/etc/sysconfig/static-routes
 
Eth0 net 210.82.37.149 netmask 255.255.255.gw 210.82.37.158
 
Eth1 net 222.35.92.242 netmask 255.255.255.252 gw 222.35.92.241
 
Mask IP address masquerade for packets sent from two WAN ports
 
#/Sbin/modprobe ip_conntrack_ftp
 
#/Sbin/modprobe ip_nat_ftp
 
#/Sbin/iptables-t nat-A postrouting-o eth0-j masquerade
 
#/Sbin/iptables-t nat-A postrouting-o eth1-j masquerade
 
Set the default gateway to China Netcom
 
# Route add default gw 210.82.37.158
 
The egress routing policy is added. The client uses the China tietong route and the rest uses the China Netcom route.
 
  CODE:

ip rule add to 121.16.0.0/13 table cncip rule add to 121.24.0.0/14 table cncip rule add to 121.28.0.0/15 table cncip rule add to 121.30.0.0/16 table cnc      ip rule add to 121.31.0.0/16 table cnc



The rest are omitted...

Refresh route table

Ip route flush cache

4. Configure DNS

Configure your own DNS resolution on the server, and direct the domain name resolution at the Domain Name Server Provider to the server.

In this way, the query from China Netcom will feed back the IP address of the website China Netcom, and the rest will feed back the IP address of China Telecom.

Configure named. conf

CODE:

View "cnc" {match-clients {121.16.0.0/13; 121.24.0.0/14; 121.28.0.0/15; 121.30.0.0/16; 121.31.0.0/16; 121.47 the rest are omitted ...;} recursion yes; zone "zhyh.org" {type master; file "/var/named/zhyh.org. cnc ";};}; view" other "{match-clients {any ;}; recursion no; zone" zhyh.org "{type master; file "/var/named/zhyh.org ";};};



Configure zhyh.org. cnc, corresponding to the IP address of China Netcom

CODE:

$TTL 86400@ IN SOA zhyh.org. root (2006111800 ; Serial28800 ; Refresh14400 ; Retry3600000 ; Expire86400 ) ; MinimumIN NS zhyh.org.IN A 218.57.200.242IN MX 10 mailwww IN A 218.57.200.242ns1 IN A 218.57.200.242ns IN A 222.173.254.21mail IN A 218.57.200.242      1 IN PTR localhost.



Configure zhyh.org to correspond to the Telecom IP Address

 CODE

$TTL 86400@ IN SOA zhyh.org. root (2006111800 ; Serial28800 ; Refresh14400 ; Retry3600000 ; Expire86400 ) ; MinimumIN NS zhyh.org.IN A 222.173.254.21IN MX 10 mailwww IN A 222.173.254.21ns IN A 222.173.254.21ns1 IN A 218.57.200.242mail IN A 222.173.254.21      1 IN PTR localhost.



Configure 222.173.254.zone and 218.57.200.zone for reverse resolution;

CODE:

$TTL 86400@ IN SOA zhyh.org. root.zhyh.org. (200611181336007200360000086400 )IN NS localhost.242 IN PTR www.zhyh.org.242 IN PTR ns1.zhyh.org.      242 IN PTR mail.zhyh.org.



5. Configure apache and set up Virtual Hosts

CODE

# vi /etc/httpd/conf/httpd.confNameVirtualHost 218.57.200.242:80NameVirtualHost 222.173.254.21:80
     
      
       ServerName zhyh.orgDocumentRoot /var/www/html/ServerAdmin webmaster@zhyh.orgErrorLog logs/zhyh.org-error_logCustomLog "|/usr/local/sbin/cronolog /var/log/httpd/zhyh.org-access_log.%Y%m%d" combined
       
        
         RewriteEngine OnRewriteRule ^(.*)/htm/(.*)$ $1.php?$2
        
       
      
     


ServerName www.zhyh.orgDocumentRoot /var/www/html/zhyh.orgServerAdmin webmaster@zhyh.orgErrorLog logs/zhyh.org-error_logCustomLog "|/usr/local/sbin/cronolog /var/log/httpd/zhyh.org-access_log.%Y%m%d" combined

 
Related Article

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.