Set with a fixed IP address as an interface

Source: Internet
Author: User

Use a fixed IP address for interface settings. Suppose you want to configure an Ethernet interface so that it has a fixed IP address 192.168.0.111. This IP address starts with 192.168.0, so it must be in a LAN. It is assumed that 192.168.0.1 is the IP address of the Internet gateway on the LAN. Edit/etc/network/interfaces to include content similar to the following section: iface eth0 inet staticaddress 192.168.0.111netmask 255.255.255.0gateway 192.168.0.1 before the interface is activated or, you can configure other parts of the interface or perform other operations. As long as you set the appropriate commands in the "up" and "down" lines. Iface eth0 inet staticaddress 255.255.255.192.168.0.1up route add-net 10.0.0.0 netmask 255.0.0.0 gw 192.168.0.2 dev $ route del-net 10.0.0.0 netmask 255.0.0.0 gw 192.168.0.2 dev $ login echo Interface $ IFACE going up | /bin/logger-t ifupdown echo Interface $ IFACE Going down |/usr/bin/logger-t ifdown you can also choose to insert the command to/etc/network/if-up.d and/etc /network/if -In the down. d directory script. These scripts can also execute extended options. For more information, see interfaces (5 ). For example, the script contained in the resolvconf package allows you to go to/etc/resolv when the interface is activated. add the specified DNS information to the conf file: iface eth0 inet staticaddress 192.168.0.111netmask 255.255.255.0gateway 192.168.0.1dns-search somedomain. orgdns-nameservers 195.238.2.21 195.238.2.22dns-search parameter somedomain.org meets resolv. the search option parameter described in conf (5. The parameters 195.238.2.21 and 195.238.2.22 of the dns-nameservers option comply with the parameters of the nameserver option. Other identifiable options are dns-domain and dns-sortlist.

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.