ifconfig eth0 192.168.0.10 netmask 255.255.255.0 or ip addr add 192.168.0.10 dev eth0
ifcfg-eth0,ifcfg-eth1,ifcfg-eth2 ... ifcfg-eth(n)
[root@development httpd]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 # Broadcom Corporation NetLink BCM5784M Gigabit Ethernet PCIe DEVICE=eth0 BOOTPROTO=static BROADCAST=192.168.3.255 HWADDR=00:25:64:A3:59:BF IPADDR=192.168.3.40 IPV6INIT=yes IPV6_AUTOCONF=yes NETMASK=255.255.255.0 NETWORK=192.168.3.0 ONBOOT=yes
eth0:1
[root@development httpd]# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:1 [root@development httpd]# vi /etc/sysconfig/network-scripts/ifcfg-eth0:1 # Broadcom Corporation NetLink BCM5784M Gigabit Ethernet PCIe DEVICE=eth0:1 BOOTPROTO=static BROADCAST=192.168.3.255 HWADDR=00:25:64:A3:59:BF IPADDR=192.168.3.41 IPV6INIT=yes IPV6_AUTOCONF=yes NETMASK=255.255.255.0 NETWORK=192.168.3.0 ONBOOT=yes
reload network
[root@development ~]# /etc/init.d/network reload Shutting down interface eth0: [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0:
[root@development ~]# cat /etc/sysconfig/network NETWORKING=yes NETWORKING_IPV6=yes HOSTNAME=development.domain.org GATEWAY=192.168.3.1
cat >> /etc/modprobe.d/bonding.conf <<EOF alias bond0 bonding options bond0 mode=balance-alb miimon=1000 EOF cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF DEVICE="eth0" ONBOOT="yes" BOOTPROTO="none" USERCTL="no" NM_CONTROLLED="no" EOF cat > /etc/sysconfig/network-scripts/ifcfg-eth1 <<EOF DEVICE="eth1" ONBOOT="yes" BOOTPROTO="none" USERCTL="no" NM_CONTROLLED="no" EOF cat > /etc/sysconfig/network-scripts/ifcfg-bond0 <<EOF DEVICE="bond0" ONBOOT="yes" BOOTPROTO="none" TYPE="Ethernet" IPADDR=172.16.0.5 NETMASK=255.255.255.0 NETWORK=172.16.0.0 USERCTL="no" NM_CONTROLLED="no" EOF modprobe bonding mode=balance-alb miimon=1000 ifconfig bond0 up ifconfig bond0 172.16.0.5 netmask 255.255.255.0 up ip route add default via 172.16.0.254 dev bond0 ifenslave bond0 eth0 ifenslave bond0 eth1 cat >> /etc/rc.local <<EOF #------------------------- ifenslave bond0 eth0 ifenslave bond0 eth1 ip route add default via 172.16.0.254 dev bond0 #------------------------- EOF more /proc/net/bonding/bond0
Linux 系統4個物理網卡的名稱則分別為eth0,eth1,eth2,eth3。我們將四個網口橋接到br0連接埠。
你可以這樣理解 vlan 2, vlan ip 192.168.0.1,然後將4個介面劃分到vlan2, 這時這4個介面可以通過vlan 2訪問其他用戶。我只是做了一個比喻,讓你能夠理解。
# brctl addbr br0 # brctl addif br0 eth0 # brctl addif br0 eth1 # brctl addif br0 eth2 # brctl addif br0 eth3 # ifconfig eth0 0.0.0.0 # ifconfig eth1 0.0.0.0 # ifconfig eth2 0.0.0.0 # ifconfig eth3 0.0.0.0 # ifconfig br0 192.168.0.1