LoginSignup
0
0

IPアドレスの切り替え

Last updated at Posted at 2024-03-26

rcスクリプトで起動時のイーサーネットポートの接続ポートによってIPアドレスを変えるようにしてみました。

PORT=`ifconfig arge0 | grep active` 

if [ -n "${PORT}" ]; then
        ifconfig arge0 inet 10.0.1.28 netmask 255.255.255.0
        route add default 10.0.1.1
else
        ifconfig arge1 inet 192.168.1.100 netmask 255.255.255.0
        route add default 192.168.1.1
fi

arge0はPHY切り出しのWANポートでEtherswitchの機能でポートのステータスが分かります。WANポートがつながれていれば10.0.1.28で、つながれてなければLAN側に192.168.1.100が設定されます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0