Linux specifies that a host or network is accessed from an IP

Source: Internet
Author: User

Linux specifies that a host or network is accessed from an IP

There are 3 IPs on test machine A

The eth0 192.168.1.34, respectively.

Eth0:1 192.168.1.36

Eth1 192.168.1.35

First boot on test machine B Apache Access_log

Tail-f/etc/httpd/logs/access_log

Then access B on test machine A, you can see

192.168.1.34--[26/aug/2014:02:54:24 +0800] "get/http/1.1" 403 4958 "-" "mozilla/5.0 (X11; Linux x86_64; rv:17.0) gecko/20131023 firefox/17.0 "

The default is from the first IP address of the first network card.

Then execute the route add-host 192.168.1.33 Dev Eth0:1 on a

Visit B again and you'll see

192.168.1.36--[26/aug/2014:02:50:10 +0800] "get/http/1.1" 403 4958 "-" "mozilla/5.0 (X11; Linux x86_64; rv:17.0) gecko/20131023 firefox/17.0 "

And then execute on a.

Route del-host 192.168.1.33 Dev eth0:1

Route add-host 192.168.1.33 Dev eth1

Visit B again and you'll see


192.168.1.35--[26/aug/2014:02:54:41 +0800] "Get/icons/apache_pb.gif http/1.1" 304-"http://192.168.1.33/" "MOZILLA/5 .0 (X11; Linux x86_64; rv:17.0) gecko/20131023 firefox/17.0 "



If you want to specify access to a segment of the network,

Route add-net 192.168.0.0/24 Dev eth0:1



If you want to go out from the specified gateway to a host

Route add-host 192.168.1.33 GW 192.168.1.1


If you don't have a browser when you test, you can also use Curl http://192.168.1.33

Linux specifies that a host or network is accessed from an IP

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.