Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ NIC configuration parameters under Linux     - To teach you how to safely send mail (Linux)

- Camera-based face recognition OpenCV crawl and storage format (Python) (Linux)

- Linux5.8 installed phpMyAdmin was unable to issue related php-mcrypt (Database)

- How to enable fbcon in Debian (Linux)

- Virtualbox virtual machine can not copy CentOS Network (Linux)

- Linux environment variable configuration and save places (Linux)

- Linux operating system must know the security command (Linux)

- Ubuntu GCC, G ++ and fortran Version Switch (Linux)

- Installation Experience open source car Automotive Grade Linux system (Linux)

- Compile and install Ubuntu Linux 4.0.5 kernel, network and fix vmware kernel module compilation error (Linux)

- Linux System Tutorial: Ubuntu on the desktop is disabled by default keyring to unlock tips (Linux)

- Glibc support encryption by modifying the DNS (Programming)

- [Errno 4] IOError: [Errno ftp error] with yum appears as a workaround (Linux)

- Linux mention the right notes (Linux)

- How to install Ubuntu strategy game Wesnoth 1.12.0 (Linux)

- Reported too many open files Linux solutions (Server)

- The signature can not be verified under Debian (Linux)

- Install the open source database PostgreSQL 9.4 and phpMyAdmin on Ubuntu (Database)

- MongoDB in bulk timestamp change the date format (Database)

- Learning C ++ Standard Template Library and data structures (Programming)

  NIC configuration parameters under Linux
  Add Date : 2018-11-21      
  In Linux If you want to modify the parameters of the card there are many ways, the first method is to modify / etc / network / interfaces file, this approach is still valid after the restart; Another method is to use ifconfig command, this method only temporary changes card parameters after the restart will fail.

The first: Modifying interfaces file

interfaces file in / etc / network / folder, network interface configuration file, which contains configuration information for all network interfaces.

interfaces file has its own writing rules, where lines start with '#' at the beginning will be ignored by the system, so you can use as a comment. Each instruction per line, if you can write no less than with the '\' symbol as the end of this line, the next line write command.

File from the "iface", "mapping", "auto", "allow-" and "source" fields. Here is an example:

auto lo eth0
allow-hotplug eth1

iface lo inet loopback

source interfaces.d / machine-dependent

mapping eth0
    script / usr / local / sbin / map-scheme
    map HOME eth0-home
    map WORK eht0-work

iface eth0-home inet static
    up flush-mail

iface eth0-work inet dhcp

iface eth1 inet dhcp
In "auto" the beginning of the line is used to determine the physical network interface will be started when ifup -a command is run (this command will be used in the system startup script, so when the power will automatically start at the beginning of "auto" to set the NIC). Behind the "auto" field should be followed by the name of physical interfaces, interfaces file can contain multiple "auto" mode to start the network interface, ifup command starts the network equipment in order.

In "allow-" beginning of the line is used to determine those to start the network devices should be automatically activated by which subsystems. So you can use the command ifup --allow = hotplug to start those already set "allow-hotplug" network devices.

NOTE: "allow-auto" and "auto" are synonymous.

Line to "source" at the beginning of the field is used to contain other files, can be configured to split into several files. "Source" is followed by the file path, shell following wildcards can be used.

Line with "mapping" is beginning to be used to start a physical device interface to determine the logical interface name. The first line of "mapping" the field is "mapping" the beginning, followed by the same command under shell glob pattern matching syntax (such as eth *). Each "mapping" field must contain a defined script, this script uses a physical device interface name as a parameter, and will all of the following in order to "map" the beginning of the field (not including the "map" itself) provided to it as input. Before the end of the script execution will output a string, specific examples refer to / usr / share / doc / ifupdown / examples the following example files.

Mapping a name that contains the search map matching pattern and executes the first match of the field to run the script, the script output is the original name card to be mapped name.

Such as:

Configure the network by PING

Linux in dealing with PCMCIA card is a better way, you can configure a script when PCMICA card is inserted to determine the network address. However, the card comes with a notebook on a laptop, not PCMCIA cards, as is often necessary to go from the office, laboratory and between home, they often need to modify the network address. If I go to every place have been installed DHCP, then I can become eth0 set DHCP way, but my situation is: You can use DHCP at home, have to use a fixed address in offices and laboratories.

To solve this problem, we can use one mapping mechanism, the basic principle of this method is to determine the current environment by running a program, and a set of configuration options for this environment. I now use the ping is through a network gateway to determine whether the current NIC which is connected to the network, and then select the configuration of the network.

First, there is in / usr / share / doc / ifupdown / examples in a file ping-places.sh, copy it to / etc / network directory and chmod a + x /etc/network/ping-places.sh. Here is edit / etc / network / interfaces file, the following is an example:

mapping eth0 (1)
script /etc/network/ping-places.sh
map home
map office
map lab
iface home inet dhcp (2)
iface office inet static (3)
up cp /etc/resolv.conf.school /etc/resolv.conf (4)
iface lab inet static
up cp /etc/resolv.conf.school /etc/resolv.conf
For network equipment indicates the calling script /etc/network/ping-places.sh, if we can use the address
ping the address, then mapped to eth0 device home, home starts configuration. Back office and lab analogous thereto.
It represents a virtual device home use DHCP-assigned address.
Virtual office equipment represents a fixed address.
Showing after starting the network equipment also perform cp command to specify a name resolution method. In addition to up, as well as pre-up, down, and post-down can be used to specify the command before and after the start or stop the execution of a network device.
NOTE: There are some examples of network configuration and scripting required in / usr / share / doc / ifupdown / examples of.

ifup usually give a physical interface name as its first parameter is no option. ifup will also use this name as the name of the initialization logic interface, unless it is designated a "= LOGICAL" suffix format, so that ifup uses the "LOGICAL" logical name as the initialization interface.

NIC configuration examples

Loop parameters

# The loopback network interface (loopback interface configuration)
# Boot automatically stimulated lo Interface
auto lo
# Configure port loopback interface lo
iface lo inet loopback
DHCP configuration mode

# The primary network interface (Configure the Primary Network Interface)
# Boot automatically activate eth0 Interface
auto eth0
# Configure DHCP to automatically obtain the interface eth0
iface eth0 inet dhcp
Static IP address assignment

# The primary network interface (Configure the Primary Network Interface)
# Boot automatically activate eth0 Interface
auto eth0
# Configure eth0 interface static IP address settings
iface eth0 inet static
# Dns- * options are implemented by the resolvconf package, if installed (DNS Settings)
dns-search fireteam.org
Wireless card configuration

auto wlan0
iface wlan1 inet static
    wpa-ssid wifi-name
    wpa-psk wifi-passwork
- Stunning exclamation point at the Linux command line (Linux)
- How to Install SeaMonkey 2.25 for Ubuntu (Linux)
- ASP.NET 5 is connected with the Redis server on the Linux platform (Server)
- Puppet centralized configuration management system (Server)
- Configuring Android NDK development environment for Mac OS X (Linux)
- Ubuntu 14.04 Fixed update information is outdated error (Linux)
- NaSC using simple mathematical operations on Ubuntu and Elementary OS (Linux)
- The Zabbix2.4.5 source compiler installation under Ubuntu 14.04 (Server)
- Linux serial debugging tools xgcom install (Linux)
- To delete the directory and all specified files under the Mac (Linux)
- How to ensure the Linux SSH login security with one-time password (Linux)
- Ubuntu install driver manager Mint Driver Manager and Device Driver Manager (Linux)
- CentOS yum source deployment (Linux)
- 10 Regulation of painless SQL Schema (Database)
- Jetty JNDI Development combat (Linux)
- MySQL restart process can not be taken lightly (Database)
- Let Markdown code syntax highlighting and support Django1.6 (Linux)
- VMware6 achieve nat Internet (Linux)
- Linux Network Statistics Tools / Command (Linux)
- Intrusion prevention network server security maintenance tips (Linux)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.