LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-18-2019, 11:36 AM   #1
linux1122
LQ Newbie
 
Registered: Jun 2019
Posts: 2

Rep: Reputation: Disabled
ifconfig vs ip


I am able to add virtual ip using below command
ifconfig enp0s3:0 192.168.1.50 netmask 255.255.255.0 up

[root@MoonLight-Lab01 network-scripts]# ifconfig enp0s3:0
enp0s3:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.50 netmask 255.255.255.0 broadcast 192.168.1.255
ether 08:00:27:e5:ea:da txqueuelen 1000 (Ethernet)

but with Ip add command

ip a add 192.168.1.52/24 dev enp0s3:2, command was successful but I am not able to see the vip using ifconfig. However I can see using,
ip -4 -o a
2: enp0s3 inet 192.168.1.52/24 scope global secondary enp0s3\ valid_lft forever preferred_lft forever

I want to know how to add virtual IP using ip command exactly same as ifconfig.

Thanks
 
Old 06-19-2019, 06:53 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by linux1122 View Post
I am able to add virtual ip using below command
Code:
ifconfig enp0s3:0 192.168.1.50 netmask 255.255.255.0 up

[root@MoonLight-Lab01 network-scripts]# ifconfig enp0s3:0
enp0s3:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.50  netmask 255.255.255.0  broadcast 192.168.1.255
        ether 08:00:27:e5:ea:da  txqueuelen 1000  (Ethernet)
but with Ip add command
Code:
ip a add 192.168.1.52/24 dev enp0s3:2, command was successful but I am not able to see the vip using ifconfig. However I can see using, 
ip -4 -o a 2: enp0s3    inet 192.168.1.52/24 scope global secondary enp0s3\       valid_lft forever preferred_lft forever
I want to know how to add virtual IP using ip command exactly same as ifconfig.
Ok...so did you read the man page on the command??? Since you know what the ifconfig command does, reading the man page on the "ip" command will tell you what the new syntax is. And your question doesn't make sense....you're saying that you ARE able to do exactly the same things (create a virtual IP, and see it) with ip as you can with ifconfig. But your 'problem' is that you can't use the **OLD, DEPRECATED** command to see the changes??

Yes..that's exactly right. You can't.
 
Old 06-19-2019, 06:59 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Code:
ip a add 192.168.1.52/24 dev enp0s3 label enp0s3:2
An ethernet adapter can have multiple IP address without being an alias. Adding a label creates an alias like the old ifconfig

Last edited by michaelk; 06-19-2019 at 07:05 AM.
 
2 members found this post helpful.
Old 06-19-2019, 09:28 AM   #4
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by michaelk View Post
[code]Adding a label creates an alias like the old ifconfig
It's been a while since I used aliases on any of my systems but I seem to recall that "ifconfig" and "ip" had different rules about how you named/labeled the additional IP addresses. That was another initial confusion that might burn newcomers to "ip". (I haven't aliases since I switched internet providers and the new equipment freaked out when it saw multiple IP addresses with the same MAC.)
 
Old 06-19-2019, 10:17 AM   #5
linux1122
LQ Newbie
 
Registered: Jun 2019
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks for your help.

I am able to bring up the virtual IP using below command

[root@node01 ~]# ip a add 192.168.1.5/24 broadcast 192.168.1.255 label enp0s3:2 scope global dev enp0s3
[root@node01 ~]# ifconfig enp0s3:2
enp0s3:2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255
ether 08:00:27:c9:c4:82 txqueuelen 1000 (Ethernet)

[root@node01 ~]#

[root@node01 ~]# ifdown enp0s3:2
usage: ifdown <configuration>
[root@node01 ~]# ip link set enp0s3:2 down

The above command completely brought down my main interface instead of virtual interface. I want to know how to bring down using IP command. (ifconfig enp0s3:2 down. This command only bring down the virtual)

Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] ifconfig -a sees eth0 ifconfig does not thllgo Linux - Networking 2 05-05-2016 03:38 PM
Why "-bash: ifconfig : command not found" when typing "$ifconfig" dangdtvn Linux - Server 9 09-20-2013 06:01 AM
connecting /sbin/ifconfig to bash command ifconfig flammable2 Fedora 4 11-12-2005 07:58 AM
ifconfig "command not found"...? GDDYUP Linux - Networking 1 09-30-2001 01:10 AM
ifconfig problems stroh78 Linux - Networking 2 03-05-2001 09:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration