/etc/network/interfaces 文件

编辑 /etc/network/interfaces 文件:

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

#lo
auto lo
iface lo inet loopback

#eth0
auto eth0
iface eth0 inet dhcp

#eth1
auto eth1
iface eth1 inet static
    address 192.168.2.233
    gateway 192.168.2.1
    netmask 255.255.255.0
    hwaddress ether AA:BB:CC:DD:EE:00

#eth2:98
auto eth2:98
iface eth2:98 inet static
    address 192.168.98.233
    gateway 192.168.98.1
    netmask 255.255.255.0

#eth2:0
auto eth2:0
iface eth2:0 inet static
    address 192.168.0.233
    gateway 192.168.0.1
    netmask 255.255.255.0

#can
source /etc/network/can.cfg

这里 lo 为回环接口;eth0、eth1 和 eth2 为三个以太网接口:
 1、将 eth0 配置成动态 IP;
 2、将 eth1 配置成静态 IP,ip 地址为 192.168.2.233,mac 地址为 AA:BB:CC:DD:EE:00;
 3、将 eth2 配置成双静态 IP,ip 地址为 192.168.98.233、192.168.0.233;
 4、运行 /etc/network/can.cfg 文件配置 can 接口。


编辑 /etc/network/can.cfg 文件:

auto can0 can1 can2

#can0
iface can0 inet manual
    pre-up /sbin/ip link set $IFACE type can bitrate 500000 sample-point 0.75 dbitrate 2000000 dsample-point 0.75 restart-ms 200 fd on
    up /sbin/ifconfig $IFACE up
    down /sbin/ifconfig $IFACE down

#can1
iface can1 inet manual
    pre-up /bin/echo 4096 > /sys/class/net/$IFACE/tx_queue_len
    pre-up /sbin/ip link set $IFACE type can bitrate 500000 restart-ms 200
    up /sbin/ifconfig $IFACE up
    down /sbin/ifconfig $IFACE down

#can2
iface can2 inet manual
    pre-up /bin/echo 4096 > /sys/class/net/$IFACE/tx_queue_len
    pre-up /sbin/ip link set $IFACE type can bitrate 500000 sample-point 0.75 dbitrate 2000000 dsample-point 0.75 restart-ms 200 fd on fd-non-iso on
    up /sbin/ifconfig $IFACE up
    down /sbin/ifconfig $IFACE down


重启网卡:

/etc/init.d/networking restart

参考:

man 5 interfaces

posted @ 2022-11-17 10:42  Ma-ZhiQiang  阅读(193)  评论(0编辑  收藏  举报