1

I was using following commands to up the devices

# ifconfig p1p1:1 10.250.0.0 netmask 255.255.0.0 up
# ifconfig p1p1:2 10.251.0.0 netmask 255.255.0.0 up
# ifconfig p1p1:3 10.252.0.0 netmask 255.255.0.0 up

I don't have ifconfig installed currently on a new device, but have ip command

I can use ip addr command to see the ip addresses of my system

what are the equivalent commands of ifconfig ... up using command ip

ip link show output is:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: p1p1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
    link/ether 00:ba:e7:ae:ed:3e brd ff:ff:ff:ff:ff:ff
3: p1p2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
    link/ether 00:ba:e7:ae:ed:3f brd ff:ff:ff:ff:ff:ff
4: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
    link/ether 60:aa:3e:25:47:1f brd ff:ff:ff:ff:ff:ff
5: em2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT qlen 1000
    link/ether 60:aa:3e:25:47:2f brd ff:ff:ff:ff:ff:ff
Cheppy
  • 23
  • 1
  • 6

1 Answers1

1

The following example will assume that your network card's name is eth0.

To bring up interface: ip link set eth0 up

To bring down interface: ip link set eth0 down

Barnabas Busa
  • 772
  • 6
  • 10
  • Barnabas, I also need to use `p1p1`, these are for connecting three different machines using internal ips – Cheppy Jan 15 '21 at 11:09
  • replace `eth0` with `p1p1` if your interface's name is `p1p1` – Barnabas Busa Jan 15 '21 at 11:10
  • if i use `ip link set p1p1:1 10.250.0.0 netmask 255.255.0.0 up` i am getting _Error: either "dev" is duplicate, or "10.250.0.0" is a garbage._ – Cheppy Jan 15 '21 at 11:12
  • This command is for putting interface up or down. To add an IP there is another command: `ip address add IPADDR/CIDR dev IFACE`. Also note you don't need any ":1" aliases, ip supports multiple addresses without all that crap. – Nikita Kipriyanov Jan 15 '21 at 11:20
  • 1
    Your original question just asked how to bring interfaces up, did not specify that you would like to set the IP address and net mask in the same command. In order to specify the IP address, subnet mask information you should take a look at the netplan config file and setup your networking details there, then bring the interfaces up. Check this link for details: https://danielmiessler.com/study/manually-set-ip-linux/ – Barnabas Busa Jan 15 '21 at 11:20
  • I want to point out explicitely `ip` from `iproute2` is not a drop-in replacement for `ifconfig`. It uses completely different approaches. It is a functional replacement for `ifconfig`, `route`, `brctl`, `vconfig`, `iptunnel`, `tunctl` and some other commands, it can do everything these can do combined and more, but command line syntax is different. – Nikita Kipriyanov Jan 15 '21 at 11:23
  • @NikitaKipriyanov you will have to excuse me for for being a noob , i am really new with network stuff i made command as per you ex: `ip address add 10.253.0.0 p1p1` where should i specify netmask? – Cheppy Jan 15 '21 at 11:30
  • I depicted that in my other comment. Usually you specify netmask length in CIDR format, like this: `10.253.0.1/16` (for the mask 255.255.0.0). BTW, your IP address/netmask pairs are wrong and can't be assigned to an interface, because they all have zeros in host part. I wrote ".1" address in my example here to reflect that. Try to use any online IP calculator out there to get a list of allowed addresses, calculate netmasks, CIDR mask length and so on. // You probably learning from ancient books or manuals. For Linux try to read LARTC, which is modern enough — https://lartc.org/howto/ – Nikita Kipriyanov Jan 15 '21 at 11:34