To make the network setup easier, Debian provides a standard advanced network Setup tool that includes ifup and Ifdown programs and/etc/network/interfaces files. If you choose to use Ifup,down to configure your network, then do not use the underlying tools to configure it at the same time. This also means that you should not use other advanced configuration tools such as Whereami, divine, intuitively, and so on. They also invoke the underlying configuration tool. The Ifup,down program is designed with the assumption that only such a program will be used to set up the network interface.
Configure fixed IP
Suppose you want to configure an Ethernet interface so that it has a fixed IP address of 192.168.0.111. Network address bit 192.168.0.0. 192.168.0.1 is the address of the gateway above this network segment. Edit the/etc/network/interfaces, configured as follows:
Auto eth0iface eth0 inet staticaddress 192.168.0.111netmask 255.255.255.0gateway 192.168.0.1
You can configure other parts of the interface or perform other operations before the interface is activated or before it is activated. As long as the appropriate commands are set in the "Up" and "Down" lines, the system automatically executes the up or down instructions after entering the ifup or ifdown instructions.
Auto eth0iface eth0 inet staticaddress 192.168.0.111netmask 255.255.255.0gateway 192.168.0.1up Route add-net 10.0.0.0 Net Mask 255.0.0.0 GW 192.168.0.2 Dev $IFACEdown Route del-net 10.0.0.0 netmask 255.0.0.0 gw 192.168.0.2 Dev $IFACEup echo in Terface $IFACE going up | /usr/bin/logger-t Ifupdown Echo Interface $IFACE going down | /usr/bin/logger-t Ifdown
You can also choose to insert commands into scripts in the/ETC/NETWORK/IF-UP.D and/ETC/NETWORK/IF-DOWN.D directories. These scripts can also perform extended options. The package resolvconf contains scripts that allow you to add the specified DNS information to/etc/resolv.conf while the interface is active:
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.22
Configuring interfaces with DHCP
Auto eth0iface eth0 inet DHCP #将static换成dhcp即可
Configuring the Wireless Card interface
Before using the wireless network card, make sure that the driver is installed, and can drive the network card, then need to install two tools wpasupplicant and Wireless-tools. To configure the/etc/network/interfaces file:
Auto Wlan0 # or Allow-hotplug wlan0iface wlan0 inet static # or dhcphwaddress ether xx:xx:xx:xx:xx:xxaddress xxx.xxx.xxx.x Xxnetmask 255.255.255.0gateway xxx.xxx.xxx.xxx#wepwireless-essid Xxxxwireless-keymode Open|restrictedwireless-key 12345|s:ascii#wpawpa-ssid Xxxxwpa-driver Wextwpa-psk Plaintext|hexadecimal
Ifdown,ifup can be followed by ~ ~
Wireless network configuration under Ubuntu