0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Linux】IPエイリアスが消えない

0
Last updated at Posted at 2020-07-17

元々ついてるIPアドレスを別のものに変更しようとしたら、なぜかどっちも付与されてしまって再起動しても消えなかった。OSはCentOS7。

・バックアップを取る

cd /etc/sysconfig/network-scripts
cp -p ifcfg-eth0 ifcfg-eth0_20180413

でバックアップをとったとします。


・IPアドレスを変更

/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
HWADDR=06:f5:9f:63:ec:b0
IPADDR=10.132.142.40
NETMASK=255.255.255.192

IPADDRの箇所を変更しました。


・再起動して反映

systemctl restart network

・結果
# ip a

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 06:f5:9f:63:ec:b0 brd ff:ff:ff:ff:ff:ff
<font color="Red">inet 10.132.142.40/26 brd 10.132.142.63 scope global eth0</font>
valid_lft forever preferred_lft forever
<font color="Red">inet 10.132.84.6/26 brd 10.132.84.63 scope global eth0</font>
valid_lft forever preferred_lft forever

???????なんで????????
再起動しても変わらず。。


調べると、どうやらバックアップの名前が原因でした。
ifcfg-eth0_yyyymmddとするとそっちまで読み込んでしまうので、
yyyymmdd_ifcfg-eth0とすれば大丈夫らしいです。


・バックアップのファイル名変更

mv ifcfg-eth0_20180413 20180413_ifcfg-eth0

・NW再起動
systemctl restart network

・確認
ip a

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 06:f5:9f:63:ec:b0 brd ff:ff:ff:ff:ff:ff
inet 10.132.142.40/26 brd 10.132.142.63 scope global eth0
valid_lft forever preferred_lft forever

消えました。
よし、じゃあバックアップを取らないでおくのが正解だな!!!!(違う)


以上

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?