最近在做solaris10下的lvs测试,需要一块网卡绑定多个ip,solaris下的操作与linux不太相同,记录以下,以备查用!
首先利用plumb激活,然后添加ip、掩码和广播地址就可以了。
# ifconfig ce0:2 plumb
# ifconfig ce0:2 172.25.198.230 netmask 255.255.0.0 broadcast 172.25.255.255 up
检查一下结果:
# ifconfig –a
lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4>mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 172.25.198.223 netmask ffff0000 broadcast 172.25.255.255
ether 0:3:ba:38:45:67
ce0:2: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 172.25.198.230 netmask ffff0000 broadcast 172.25.255.255
ce1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
inet 10.0.0.2 netmask ffffff00 broadcast 10.0.0.255
ether 0:3:ba:38:45:66
如果希望这个ip在系统启动的时候自动添加,可以将上面命令编辑成脚本添加到/etc/rcN.d目录下。
# ifconfig ce0:2 unplumb(从系统内核中关闭ce0:2接口)
上面的操作在重启系统以后,网卡绑定将失效,除非设置开机自动执行上面的操作。那么如何才能设置永久生效呢,看下面操作。
举例说明,网卡名hme0:
# vi /etc/hosts
127.0.0.1 localhost
192.168.66.123 dba loghost
192.168.60.15 webserver1
192.168.60.65 webserver2
# vi /etc/netmasks
192.168.66.0 255.255.255.0
192.168.60.0 255.255.255.192
192.168.60.64 255.255.255.252
#vi /etc/hostname.hme0
dba
创建以下两个文件/etc/hostname.hme0:1 /etc/hostname.hme0:2,内容如下:
#vi /etc/hostname.hme0:1
webserver1
#vi /etc/hostname.hme0:2
Webserver2
设置生效
#ifconfig hme0:1 plumb
#ifconfig hme0:2 plumb
# ifconfig hme0 inet 192.168.66.123 netmask 255.255.255.0 up
# ifconfig hme0:1 inet 192.168.60.15 netmask 255.255.255.192 up
# ifconfig hme0:2 inet 192.168.60.65 netmask 255.255.255.252 up
重启系统,查看
# init 6 或者reboot
#ifconfig -a