虚拟机默认我只给了一个网卡,也就是NAT方式,它会随机分配一个10.0
段的IP,然后通过端口映射去连接虚拟机。
然后我想增加一张网卡,让它通过桥接
的方式,分配局域网IP192.168
段的
vi /etc/network/interfaces
auto loiface lo inet loopbackauto eth0iface eth0 inet dhcp hostname localhost
我在eth0
下方添加了一个eth1
auto loiface lo inet loopbackauto eth0iface eth0 inet dhcpauto eth1iface eth1 inet dhcp hostname localhost
然后重启网络服务
service networking restart
应该就OK了,至于静态IP...
将刚添加的地方略做修改即可
iface eth1 inet static address 192.168.1.150 netmask 255.255.255.0 gateway 192.168.1.1
开启ipv6支持
modprobe ipv6echo "ipv6" >> /etc/modules
自动获取ipv6
iface eth1 inet6 manual pre-up echo 1 > /proc/sys/net/ipv6/conf/eth1/accept_ra
配置固定的ipv6地址
iface eth1 inet6 static address 2001:250:ffff:ff::2 netmask 64 gateway 2001:250:ffff:ff::1 pre-up echo 0 > /proc/sys/net/ipv6/conf/eth1/accept_ra
也可以同时配置
auto loiface lo inet loopbackauto eth1iface eth1 inet static address 192.168.1.150 netmask 255.255.255.0 gateway 192.168.1.1iface eth1 inet6 static address 2001:250:ffff:ff::2 netmask 64 gateway 2001:250:ffff:ff::1 pre-up echo 0 > /proc/sys/net/ipv6/conf/eth1/accept_ra