1. 程式人生 > >轉載:給debian的單網絡卡配置多IP時的提示資訊

轉載:給debian的單網絡卡配置多IP時的提示資訊

Debian Linux command to get into network interface card

#vi /etc/network/interfaces

How to assign multiple IP addresses in debian linux:

You can assign multiple IP addresses to the same network interface by using interface alias. This is useful if you need to have more than one server visible on the internet. Note that for multiple Apache servers you can use virtual hosts to add as many servers as you like with one single IP address.Apache simply utilises the domain name supplied by the client in the http host header.

You must turn off dhcp because you must use static assignment if you are configuring multiple IPs, so basically this file is:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.90
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255

Assuming that you interface is eth0, you can assign three IP addresses editing /etc/network/interfaces similar to this:

# the loopback interface
auto lo
iface lo inet loopback

#
auto eth0
iface eth0 inet static
address 192.168.1.42
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1

auto eth0:0
iface eth0:0 inet static
address 192.168.1.41
netmask 255.255.255.0
broadcast 192.168.1.255

auto eth0:1
iface eth0:1 inet static
address 192.168.1.43
netmask 255.255.255.0
broadcast 192.168.1.255

auto eth0:2
iface eth0:2 inet static
address 192.168.1.44
netmask 255.255.255.0
broadcast 192.168.1.255

Note that gateway is only assigned to eth0. If you include dns-nameservers, it should also only be specified for eth0.

If you make changes to this file you can cause them to take effect by running:
/etc/init.d/networking restart

# /etc/init.d/networking restart
Reconfiguring network interfaces…if-up.d/mountnfs[eth0]: waiting for interface eth0:0 before doing NFS mounts (warning).
if-up.d/mountnfs[eth0]: waiting for interface eth0:1 before doing NFS mounts (warning).
if-up.d/mountnfs[eth0]: waiting for interface eth0:2 before doing NFS mounts (warning).
if-up.d/mountnfs[eth0:0]: waiting for interface eth0:1 before doing NFS mounts (warning).
if-up.d/mountnfs[eth0:0]: waiting for interface eth0:2 before doing NFS mounts (warning).
if-up.d/mountnfs[eth0:1]: waiting for interface eth0:2 before doing NFS mounts (warning).
done.

How to fix  if-up.d/mountnfs[eth0:1]: waiting for interface eth0:2 before doing NFS mounts (warning). ?

Reconfiguring network interfaces…if-up.d/mountnfs[eth0]: waiting for interface eth0:0 before doing NFS mounts (warning).
if-up.d/mountnfs[eth0]: waiting for interface eth0:1 before doing NFS mounts (warning).
if-up.d/mountnfs[eth0]: waiting for interface eth0:2 before doing NFS mounts (warning).
if-up.d/mountnfs[eth0:0]: waiting for interface eth0:1 before doing NFS mounts (warning).
if-up.d/mountnfs[eth0:0]: waiting for interface eth0:2 before doing NFS mounts (warning).
if-up.d/mountnfs[eth0:1]: waiting for interface eth0:2 before doing NFS mounts (warning).
done.

Solution:

It means that it is making sure that all ‘net interfaces are up before trying to mount a network based filesystem.

# chmod -x /etc/network/if-up.d/mountnfs

合理的解釋:

I wouldn't worry too much. It appears to be a warning that can be ignored in the presence of multiple interfaces.

What is happening is that the primary eth0 interface is brought up (via ifup) due to its entry in /etc/network/interfaces. In response to that, scripts in /etc/network/if-up.d will run automatically. And one of those scripts is mountnfs to automatically mount any filesystems in /etc/fstab that are marked as nfs. You'll find the code that generates the warning in /etc/network/if-up.d/mountnfs.

I'm guessing at why the code was written this way, but since the script can't tell with certainty which (if you have multiple) of your network interfaces may be needed for the NFS mount to succeed, it checks all the "auto" interfaces in /etc/network/interfaces and if any aren't configured yet, it exits with the warning you saw. In your case, you have a second, eth0:0, alias interface, that holds your secondary address which isn't up yet - thus the warning.

But since the same script will then re-run on each subsequent interface coming up, when it gets to the final interface it proceeds to mount any network filesystems.

From the script on Debian (assuming Debian 5 - I don't have a Debian 4 image to check), it appears that the "am I the last interface to come up" check is done even before checking fstab so you can get this warning even if you don't have any nfs filesystems configured.

If the message annoys you, and you don't have any nfs mounts, you can always get rid of the mountnfs script in /etc/network/if-up.d, or chmod -x the script, which will cause it to be skipped.