3 Star 0 Fork 0

mirrors_zephyrproject-rtos/net-tools

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
zeth-multiface.conf 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
# Configuration file for setting IP addresses for multiple network interface.
INTERFACE_PREFIX="$1"
HWADDR_PREFIX="00:00:5e:00:53:"
IPV6_ADDR_PREFIX0="2001:db8::"
IPV6_ROUTE0="2001:db8::/64"
IPV6_ADDR_PREFIX1="2001:db8:2::"
IPV6_ROUTE1="2001:db8:2::/64"
IPV4_ADDR_PREFIX0="192.0.2."
IPV4_ADDR_PREFIX1="198.51.100."
INTERFACE0=${INTERFACE_PREFIX}
INTERFACE1=`echo ${INTERFACE_PREFIX} | sed "s/0/1/g"`
IPV4_ROUTE0="${IPV4_ADDR_PREFIX0}0/24"
IPV4_ROUTE1="${IPV4_ADDR_PREFIX1}0/24"
# The zeth0 is already created by net-setup script so avoid
# doing it twice.
ip link set dev ${INTERFACE0} up
ip link set dev ${INTERFACE0} address ${HWADDR_PREFIX}0
ip -6 address add ${IPV6_ADDR_PREFIX0}2 dev $INTERFACE0 nodad
ip -6 route add $IPV6_ROUTE0 dev $INTERFACE0
ip address add ${IPV4_ADDR_PREFIX0}2 dev $INTERFACE0
ip route add $IPV4_ROUTE0 dev $INTERFACE0 2>&1
COUNT=${COUNTER:-2}
INTERFACE_TMPL=`echo ${INTERFACE_PREFIX} | sed "s/0//g"`
for ((i = 1; i < $COUNT; i++ )); {
iface_idx=$i
INTERFACE=${INTERFACE_TMPL}${iface_idx}
ip tuntap add ${INTERFACE} mode tap
ip link set dev ${INTERFACE} up
# If there are config options then try to apply them.
# TODO: this should be changed to use a yaml file or similar.
VAR_CHECK="INTERFACE${iface_idx}"
if [ -n "${!VAR_CHECK}" ]; then
ip link set dev ${INTERFACE} address ${HWADDR_PREFIX}${iface_idx}
VAR=IPV6_ADDR_PREFIX${iface_idx}
ip -6 address add ${!VAR}${iface_idx} dev ${INTERFACE} nodad
VAR=IPV6_ROUTE${iface_idx}
ip -6 route add ${!VAR} dev ${INTERFACE}
VAR=IPV4_ADDR_PREFIX${iface_idx}
ip address add ${!VAR}${iface_idx} dev ${INTERFACE}
VAR=IPV4_ROUTE${iface_idx}
ip route add ${!VAR} dev ${INTERFACE} 2>&1
fi
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_zephyrproject-rtos/net-tools.git
git@gitee.com:mirrors_zephyrproject-rtos/net-tools.git
mirrors_zephyrproject-rtos
net-tools
net-tools
master

搜索帮助