赞
踩
sudo add-apt-repository ppa:expert360/ppa
sudo apt-get update
sudo apt-get install ec2-net-utils
查看所有的网络接口
ifconfig -a
ls /sys/class/net
lshw -C Network
查询启动信息
dmesg | grep eth1
安装ec2-net-utils,会自动添加网卡,也可以用命令添加网卡(添加网卡前,可以先将内网ip添加到网卡,如果添加网卡后启动不了,先分离网卡再重新添加)
sudo env INTERFACE=eth1 ACTION=add /etc/network/ec2net.hotplug add
cat /etc/network/interfaces.d/eth1.cfg
auto eth1 iface eth1 inet dhcp post-up ip route add default via 172.31.0.1 dev eth1 table 10001 post-up ip route add default via 172.31.0.1 dev eth1 metric 10001 sudo tee /etc/network/interfaces.d/eth1.cfg <<-'EOF' auto eth1 iface eth1 inet dhcp post-up ip route add default via 172.31.0.1 dev eth1 table 10001 post-up ip route add default via 172.31.0.1 dev eth1 metric 10001 EOF sudo tee /etc/network/interfaces.d/eth2.cfg <<-'EOF' auto eth2 iface eth2 inet dhcp post-up ip route add default via 172.31.0.1 dev eth2 table 10001 post-up ip route add default via 172.31.0.1 dev eth2 metric 10001 EOF
cat /etc/dhcp/dhclient-eth1.conf
supersede dhcp-server-identifier 255.255.255.255;
sudo tee /etc/dhcp/dhclient-eth1.conf <<-'EOF'
supersede dhcp-server-identifier 255.255.255.255;
EOF
sudo tee /etc/dhcp/dhclient-eth2.conf <<-'EOF'
supersede dhcp-server-identifier 255.255.255.255;
EOF
sudo ifup eth1
sudo ip addr add 172.x.x.x/20 dev eth0
sudo ifdown eth0
sudo ifup eth0
sudo vi /etc/rc.local
在 exit 0 之前加入代码
sudo ip addr add 172.x.x.x/20 dev eth0
查看已添加的私有IP
ip addr list dev eth0
如果要删除添加的私有 ip 只需要把 add 改为 del :
sudo ip addr del 172.x.x.x/20 dev eth0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。