• PRO Courses Guides New Tech Help Pro Expert Videos About wikiHow Pro Upgrade Sign In
  • EDIT Edit this Article
  • EXPLORE Tech Help Pro About Us Random Article Quizzes Request a New Article Community Dashboard This Or That Game Popular Categories Arts and Entertainment Artwork Books Movies Computers and Electronics Computers Phone Skills Technology Hacks Health Men's Health Mental Health Women's Health Relationships Dating Love Relationship Issues Hobbies and Crafts Crafts Drawing Games Education & Communication Communication Skills Personal Development Studying Personal Care and Style Fashion Hair Care Personal Hygiene Youth Personal Care School Stuff Dating All Categories Arts and Entertainment Finance and Business Home and Garden Relationship Quizzes Cars & Other Vehicles Food and Entertaining Personal Care and Style Sports and Fitness Computers and Electronics Health Pets and Animals Travel Education & Communication Hobbies and Crafts Philosophy and Religion Work World Family Life Holidays and Traditions Relationships Youth
  • Browse Articles
  • Learn Something New
  • Quizzes Hot
  • This Or That Game
  • Train Your Brain
  • Explore More
  • Support wikiHow
  • About wikiHow
  • Log in / Sign up
  • Computers and Electronics
  • Operating Systems

How to Assign an IP Address on a Linux Computer

Last Updated: April 11, 2024 Tested

Debian, Ubuntu, & Linux Mint

Red hat, centos, & fedora.

This article was co-authored by wikiHow staff writer, Jack Lloyd . Jack Lloyd is a Technology Writer and Editor for wikiHow. He has over two years of experience writing and editing technology-related articles. He is technology enthusiast and an English teacher. The wikiHow Tech Team also followed the article's instructions and verified that they work. This article has been viewed 731,637 times. Learn more...

This wikiHow teaches you how to assign a new IP address to your computer when using Linux. Doing so can prevent connection issues for the item in question.

Assign an IP Address to a Debian, Ubuntu, or Linux Mint Computer

No matter what version of Linux you're running, you'll need to open the Terminal and switch to root. In Debian, Ubuntu, and Linux Mint, use the "ipconfig" command to view your Internet items. Find the item you want to assign an IP address to, then type "sudo ipconfig [name] [ipaddress] netmask 255.255.255.0 up".

Step 1 Verify your Linux version.

  • Press Ctrl + Alt + T or Ctrl + Alt + F1 (if you're on a Mac, substitute the ⌘ Command key for Ctrl .
  • Click the text box at the top or bottom of the screen if possible.
  • Open the Menu window and find the "Terminal" application, then click on it.

Step 3 Switch to root.

  • A "root" account is the Linux equivalent of an Administrator account on a Windows or Mac computer.

Step 4 Bring up a list of your current Internet items.

  • The top item should be your current router or Ethernet connection. This item's name is "eth0" (Ethernet) or "wifi0" (Wi-Fi) in Linux.

Step 5 Find the item to which you want to assign an IP address.

  • In most cases, this is the "eth0" or "wifi0" item.

Step 6 Change the item's IP address.

  • To assign an IP of "192.168.2.100" to your ethernet connection ("eth0"), for example, you'd enter sudo ifconfig eth0 192.168.0.100 netmask 255.255.255.0 here.

Step 7 Assign a default gateway.

  • If you have a different DNS server address that you would rather use, enter that in the place of 8.8.8.8 .

Step 9 Check your item's new IP address.

  • 5 Find the network connection that you want to change. This will normally be the Ethernet or Wi-Fi connection, which has an IP address currently listed on the right side of the window.

Step 6 Switch to the network scripts directory.

  • For a network named "eno12345678", for example, you'd enter vi ifcfg-eno12345678 here.

Step 9 Edit the network's information.

  • BOOTPROTO - Change dhcp to none
  • Any IPV6 entry - Delete any IPV6 entries entirely by moving the cursor to the I on the left and pressing Del .
  • ONBOOT - Change no to yes

Step 10 Enter a new IP category.

  • For example: to use "192.168.2.23" as your IP address, you'd type in IPADDR=192.168.2.23 and press ↵ Enter .
  • Type in PREFIX=24 and press ↵ Enter . You can also enter NETMASK=255.255.255.0 here.
  • Type in GATEWAY=192.168.2.1 and press ↵ Enter . Substitute your preferred gateway address if different.

Step 12 Save and exit the file.

Expert Q&A

  • Some very specific Linux distributions will require you to go through a different process to assign an IP address. To see your specific distribution's specifications, check online. Thanks Helpful 0 Not Helpful 0

how to assign ip address to eth0 in linux

  • Don't forget to switch back to the regular (non-root) user account when you're done. Thanks Helpful 1 Not Helpful 1

You Might Also Like

Set up a Network in Ubuntu

  • ↑ https://danielmiessler.com/study/set_ip/
  • ↑ https://www.youtube.com/watch?v=oQd5eG9BZXE&t=

About This Article

Jack Lloyd

  • Send fan mail to authors

Reader Success Stories

Buddy HaDagi

Buddy HaDagi

Jan 27, 2017

Is this article up to date?

how to assign ip address to eth0 in linux

Dmitry Ugay

Oct 10, 2017

Am I a Narcissist or an Empath Quiz

Featured Articles

130+ Sexy, Sweet, & Seductive Messages for Him

Trending Articles

How to Answer “How’s It Going?” in Any Situation

Watch Articles

Make Homemade Liquid Dish Soap

  • Terms of Use
  • Privacy Policy
  • Do Not Sell or Share My Info
  • Not Selling Info

Keep up with tech in just 5 minutes a week!

How-To Geek

How to change your ip address from the command line in linux.

It's easy to change your IP address using a graphic interface, but did you know that Linux also lets you change your network card's IP address using a simple command from the command line?This trick should work on all Debian-based Linux distros, including Ubuntu.

It's easy to change your IP address using a graphic interface, but did you know that Linux also lets you change your network card's IP address using a simple command from the command line?

This trick should work on all Debian-based Linux distros, including Ubuntu. To get started, type

at the terminal prompt, and then hit Enter. This command lists all network interfaces on the system, so take note of the name of the interface for which you want to change the IP address.

To change the settings, you also use the ifconfig command, this time with a few additional parameters. The following command changes the network interface named "eth0" to use the IP address 102.168.0.1, and assigns the subnet mask 255.255.255.0:

sudo ifconfig eth0 192.168.0.1 netmask 255.255.255.0

You could, of course, substitute in whatever values you want. If you run ifconfig again, you will see that your interface has now taken on the new settings you assigned to it.

If you also need to change the Default Gateway used by the network interface, you can use the route command. The following command, for example, sets the default gateway for the "eth0" interface to 192.168.0.253:

sudo route add default gw 192.168.0.253 eth0

To see your new setting, you will need to display the routing table. Type the following command at the prompt, and then hit Enter:

Related: How to Work with the Network from the Linux Terminal: 11 Commands You Need to Know

That's all there is to changing your IP address from the terminal. If you're interested in other great networking tools you can use at the terminal, be sure to check out our guide to the subject.

RELATED:   Best Linux Laptops for Developers and Enthusiasts

Tecmint: Linux Howtos, Tutorials & Guides

How to Set Static IP Address and Configure Network in Linux

If you are a Linux system administrator, time will come when you will need to configure networking on your system. Unlike desktop machines where you can use dynamic IP addresses, on a server infrastructure, you will need to setup a static IP address (at least in most cases).

Read Also: How to Set or Change System Hostname in Linux </p

This article is meant to show you how to configure static IP address on most frequently used Linux distributions.

For the purpose of this tutorial, we will use the following Internet Protocol version 4 (IPv4) details:

Configure Static IP Address in RHEL/CentOS/Fedora:

To configure static IP address in  RHEL / CentOS / Fedora , you will need to edit:

Where in the above "ifcfg-eth0" answers to your network interface eth0 . If your interface is named “ eth1" then the file that you will need to edit is "ifcfg-eth1" .

Let’s start with the first file:

Open that file and set:

Note : Make sure to open the file corresponding to your network interface. You can find your network interface name with ifconfig -a command .

In that file make the following changes:

You will only need to edit the settings for:

  • DNS1 and DNS2

Other settings should have already been predefined.

Next edit resolve.conf file by opening it with a text editor such as nano or vi :

Once you have made your changes restart the networking with:

Set Static IP Address in Debian / Ubuntu

To setup static IP address in Debian / Ubuntu , open the following file:

You may see a line looking like this:

Change it so it looks like this:

Save the file and then edit /etc/resolv.conf like this:

Restart the networking on your system with:

Your static IP address has been configured.

Conclusion:

You now know how to configure a static IP address on a Linux distro. If you have any questions or comments, please do not hesitate to submit them in the comment section below.

Previous article:

Next article:

Photo of author

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Related Posts

chkconfig vs systemctl

chkconfig vs. systemctl: Manage Linux Services Efficiently

Send Mail From Linux Terminal

Mutt – A Command Line Email Client to Send Mails from Terminal

dpkg Command Examples

15 Useful ‘dpkg’ Commands for Debian/Ubuntu Users

Advance Commands for Linux Experts

Sysadmins & DevOps: 20 Must-Know Advanced Linux Commands

Unmount USB Drive in Linux

How to Safely Eject a USB Drive in Linux

Make File and Directory Undeletable in Linux

How to Make File and Directory Undeletable, Even By Root in Linux

34 Comments

There isn’t an “eth0” on my server because it is connected by WIFI only.

@Thuemaychuaonet,

If your server is connected only via WiFi, the network interface will likely have a different name, such as ` wlan0 ` or something similar, depending on your system and its configuration.

The steps to set a static IP address and configure the network are similar, but you’ll need to use the correct interface name for your WiFi connection.

You can find the name of your WiFi interface by running the ` ip a` command in the terminal. Once you have the correct interface name, you can follow the same process to configure your network settings.

The time will come when you will need to configure networking on your system. Unlike desktop machines where you can use dynamic IP addresses, on a server infrastructure, you will need to set up a static IP address (at least in most cases).

Terrible – and my ‘ linux distro ‘ isn’t the same as yours, there’s no ‘ /etc/sysconfig/ ‘ folder.

In Ubuntu 20.04 there is no interfaces file they switch to netplan . If you can update this article to include the new change it will help a lot.

thanks Raouf

Well, this isn’t correct. Just trashed my Linux mint distro

Is it public Static IP? or can I use to access data from other networks?

Failed to restart network.service: Unit network.service not found.

I’m asking a question on a fairly old thread, but just in case, is it possible to do this on a WIFI network?

For example, when using the first command (# nano /etc/network/interfaces ) in Ubuntu, the result I see is:

There isn’t an “ eth0 ” on my server because it is connected by WIFI only. Will it still work using another option?

Yes it will work I think so, just change the settings in the interfaces file as explained in this article.

I set the static IP in ifcfg-eth0, added HWADDR and UUID, but on reboot system does not associate the IP to eth0.

This is VM. Any idea why its happening and steps to troubleshoot.

I think you need to make sure that you select “ manual ” and the correct IP address, subnet mask, and gateway and save the configuration as explained in the article. Also, I personally would select a new and different IP address, so that you can really check if it has been saved by opening the terminal and typing:

after a restart.

If i set ip address as static am not able to ping google.com why and also packages are not installed.

Please give me reply as soon as possible.

@Rajeshkar,

Please add the DNS Name servers in your /etc/resolv.conf file..

@Ravi Saive thanks for your reply , yes i did /etc.resolv.conf also but getting the same problem

@Rajesekar,

The file is /etc/resolv.conf , in this file add your DNS name servers for example.

When I enter the /etc/resolv.conf file, what is it supposed to look like? And when you say “edit” do you mean delete what’s there and write what you’ve provided, or just add new lines?

Hello Marin, Thank you very much for this article. It was a major help in my class project. This is my first time using a vm and it is an awesome learning experience. I’m really glad I ran into this article, it was well written and easy to follow.

Just wanted to say a million thank you’s for this well-written, comprehensive and easily-understood article! Awesome stuff! A real lifesaver too, as I had to quickly configure a static IP for myself to get access to remote computing. Thank you! :-D

A question from a linux newbie. Does this instruction apply for both ubuntu running on my desktop PC as well as debian linux on an embedded board?

Yes, the instructions will works on any Debian/Ubuntu based distribution without any issues..have you tried on your embedded board? does these instructions worked? let us know.

Hi Ravi, thanks for your reply.

Default the folder /etc/sysconfig does not exist on my embedded system. Of Course i could create it as well as the files mentioned, but it would be out of the context of this instructions.

Thanks, Rob

I found here very good stuff! You are doing an excellent job and I like your site! Thanks!

Thanks for finding this site very useful and thanks for appreciating our work, Keep visiting for more such useful articles…

Great job, I was I actually looking for an article like this one. So thank you so very much. Keep up the good work.

Thanks for appreciating and finding this article useful, keep connected to Tecmint for such wonderful articles…:)

What if I have 2 NICs on my server one for LAN & one for WAN and I want to set one of them (WAN) as default gateway? How to configure this server as gateway and as a router.

The easiest way to add default gateway using route command as shown:

Don’t forget to replace the gateway IP address and interface-name in the above command.

One can also use following command to setup static IP on eth0 interface for example. # ifconfig eth0 192.168.1.1 netmask 255.255.255.0 up # route add default gw 192.168.0.1 # service network restart

Thanks for the tip, but I think setting IP address directly from the commandline using ifconfig and route will only allow you to set temporarily, once you reboot, these settings disappears. So, the best option to set static IP address permanently in network configuration files only….

wipe on reboot, so that best option is to set permannetly

Hello Ravi, What is difference between the service “NetworkManager” and “network”

@Augustine,

This article will help you to understand the difference between and NetworkManager and Network: http://askubuntu.com/questions/1786/what-is-the-difference-between-network-manager-and-ifconfig-ifup-etc

Why do we need to specify DNS in both ifcfg-eth0 and resolvlf.conf?

Hello Augustine,

Actually if you have added the DNS servers in the ifcfig-eth0 file the DNS servers will be automatically added to /etc/resolv.conf. You can skip defining the DNS servers in the ifcfig-eth0 file, but then you will need to have them set in /etc/resolv.conf manually. It’s a good practice to make sure that the DNS servers are specified correctly in both files, this is why the article says to set them in both files.

Got Something to Say? Join the Discussion... Cancel reply

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.

Save my name, email, and website in this browser for the next time I comment.

  • Command Line Interface (CLI)
  • Denial-of-Service Attack (DoS)
  • Desktop Managers
  • Linux Administration
  • Virtual Private Network (VPN)
  • Wireless LAN (Wi-Fi)
  • Privacy Policy

blackMORE Ops Learn one trick a day ….

Setup dhcp or static ip address from command line in linux.

March 26, 2015 Command Line Interface (CLI) , How to , Linux , Linux Administration , Networking 25 Comments

This guide will guide you on how to setup DHCP or static IP address from command Line in Linux. It saved me when I was in trouble, hopefully you will find it useful as well. In case you’ve only got Wireless, you can use this guide to connect to WiFi network from command line in Linux .

Note that my network interface is eth0 for this whole guide. Change eth0 to match your network interface.

Static assignment of IP addresses is typically used to eliminate the network traffic associated with DHCP/DNS and to lock an element in the address space to provide a consistent IP target.

Step 1 : STOP and START Networking service

Some people would argue restart would work, but I prefer STOP-START to do a complete rehash. Also if it’s not working already, why bother?

Step 2 : STOP and START Network-Manager

If you have some other network manager (i.e. wicd, then start stop that one).

Just for the kicks, following is what restart would do:

Step 3 : Bring up network Interface

Now that we’ve restarted both networking and network-manager services, we can bring our interface eth0 up. For some it will already be up and useless at this point. But we are going to fix that in next few steps.

The next command shows the status of the interface. as you can see, it doesn’t have any IP address assigned to it now.

Step 4 : Setting up IP address – DHCP or Static?

Now we have two options. We can setup DHCP or static IP address from command Line in Linux. If you decide to use DHCP address, ensure your Router is capable to serving DHCP. If you think DHCP was the problem all along, then go for static.

Again, if you’re using static IP address, you might want to investigate what range is supported in the network you are connecting to. (i.e. some networks uses 10.0.0.0/8, some uses 172.16.0.0/8 etc. ranges). For some readers, this might be trial and error method, but it always works.

Step 4.1 – Setup DHCP from command Line in Linux

Assuming that you’ve already completed step 1,2 and 3, you can just use this simple command

The first command updates /etc/network/interfaces file with eth0 interface to use DHCP.

The next command brings up the interface.

With DHCP, you get IP address, subnet mask, broadcast address, Gateway IP and DNS ip addresses. Go to step xxx to test your internet connection.

Step 4.2 – Setup static IP, subnet mask, broadcast address in Linux

Use the following command to setup IP, subnet mask, broadcast address in Linux. Note that I’ve highlighted the IP addresses in red . You will be able to find these details from another device connected to the network or directly from the router or gateways status page. (i.e. some networks uses 10.0.0.0/8, some uses 172.16.0.0/8 etc. ranges)

Next command shows the IP address and details that we’ve set manually.

Because we are doing everything manually, we also need to setup the Gateway address for the interface. Use the following command to add default Gateway route to eth0 .

We can confirm it using the following command:

Step 4.3 – Alternative way of setting Static IP in a DHCP network

If you’re connected to a network where you have DHCP enabled but want to assign a static IP to your interface, you can use the following command to assign Static IP in a DHCP network, netmask and Gateway.

At this point if your network interface is not up already, you can bring it up.

Step 4.4 –  Fix missing default Gateway

Looks good to me so far. We’re almost there.

Try to ping http://google.com/ (cause if www.google.com is down, Internet is broken!):

Step 5 : Setting up nameserver / DNS

For most users step 4.4 would be the last step. But in case you get a DNS error you want to assign DNS servers manually, then use the following command:

This will add Google Public DNS servers to your resolv.conf file. Now you should be able to ping or browse to any website.

Losing internet connection these days is just painful because we are so dependent on Internet to find usable information. It gets frustrating when you suddenly lose your GUI and/or your Network Manager and all you got is either an Ethernet port or Wireless card to connect to the internet. But then again you need to memorize all these steps.

I’ve tried to made this guide as much generic I can, but if you have a suggestion or if I’ve made a mistake, feel free to comment. Thanks for reading. Please share & RT.

Enabling AMD GPU for Hashcat on Kali Linux: A Quick Guide

Enabling AMD GPU for Hashcat on Kali Linux: A Quick Guide

If you’ve encountered an issue where Hashcat initially only recognizes your CPU and not the …

Boot Ubuntu Server 22.04 LTS from USB SSD on Raspberry Pi 4

Boot Ubuntu Server 22.04 LTS from USB SSD on Raspberry Pi 4

This is a guide for configuring Raspberry Pi4 to boot Ubuntu from external USB SSD …

25 comments

' src=

Just wanted to say, your guides are amazing and should be included into kali’s desktop help manual. Thanks for your awesome work!

' src=

Hi Matt, That’s very kind, thank you. I’m happy that my little contributions are helping others. Cheers, -BMO

' src=

I’ve gone through the steps listed in Step 4.2 and when I check my settings are correct, until I reboot. After I reboot all my settings have reverted back to the original settings. Any ideas?

' src=

The only problem with this is that nowadays Linux machines aren’t always shipped with the tools you use. They are now shipped with the systemd virus so the whole init.d doens’t work anymore and ifconfig isn’t shipped on a large number of distro’s.

Hi, The intention was to show what to do when things are broken badly. In my case, I’ve lost Network Manager and all of Gnome Desktop. I agree this is very old school but I’m sure it’s better than reinstalling. Not sure what distro you’re talking about. I use Debian based Kali (and Debian Wheezy), CentOS(5,6,7) and Ubuntu for work, personal and testing. ifconfig is present is every one of them. ifconfig also exists in all variants of server distro, even in all Big-IP F5’s or CheckPoint Firewalls. Hope that explains my inspiration for this article. Cheers, -BMO

' src=

Hi , I want to say Thank you for your Guide, it’s very useful. and want to add another method for Step 5 : Setting up nameserver / DNS: add nameserver directly to resolv.conf file

nano /etc/resolv.conf

Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)

DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN

nameserver 8.8.8.8 nameserver 8.8.4.4 search Home

' src=

nano or vi is not requiered, use “printf” instead “echo”… e.g:

printf “nameserver 8.8.8.8\nnameserver 8.8.4.4\n” >> /etc/resolv.conf

double-check with:

grep nameserver /etc/resolv.conf

' src=

Hey I’m new to VM my eth0 inet addr is 10.0.02.15 but every video I watch their inet addr always starts with 192. I was wondering what I can do to change my inet addr to start with 192. Is this guide a solution

Hi Billy Bob, Is 10.x address coming from VBox internal or from your router? You possibly selected Bridged network. Try juggling between Bridged and NAT. Also look up VBox IP addressing in Google. Cheers -BMO

' src=

Please help, I’ve done all these steps and still I don’t have internet connection with bridged adapter. When I set NAT I have internet connection but with bridged adapter i don’t. I checked with ifconfig eth0 command and I have ip, netmask and broadcast ip. What could be the problem?

' src=

Excellent guide. I haven’t been using any debian based linux distros in a while and forgot where the entries go manually. I was actually kind of surprised how long it took to find your page in google, there is a lot of pages that don’t actually answer the question, but yours was spot on.

' src=

I did all the commands but my IP address doesn’t show up, and now my internet server on Linux iceweasel is down. It’s telling me that “Server not found” I really need help.

' src=

Hi Blackmoreops Thanks for the tutorial. I do have a question tho, in kalisana, I have followed your advice step by step to configure a static ip on my kali VM. But when I check with ifconfig, I still get the ip assigned by my modem? I run the kali vm on fedora 22 host… Is there a way around this? Regards Adexx

' src=

Hey Blackmoreops, Thanks for the great article. Being a total NOOB, I’m wondering if these are the last steps in getting my correct lab setting to enumerate De-Ice 1.100 with nmap. My current setting on Kali 2016 machine are: add:192.168.1.5 , mask: 255.255.255.0, default gw 192.168.1.1. Both machine set to NAT in Virtualbox 5. I’ve tried numerous scans ie., ping, list proctocol verify, and stealth and I’m unable to find any open ports. Help!!!!!!!

Best Regards. C

' src=

i tried on my kali linux but i lost my internet connection

' src=

hello everyone i have got problem on my kali linux with internet. Kali is connected to my wifi but iceweasel can’t open any site. Can you help me solve this problem please ?

' src=

check mtu and DNS

' src=

Followed through all the steps, and it worked. Then I restarted the router, and everything is back to the earlier configuration?

' src=

thanks for tutorial.bu how change the ip that blocked by google :D

' src=

Hello sorry but wasnt able to configure my network. I installed kali into my hdd and im using it as my main OS on this pc(idk if thats recommended or not) . I am curently connected to the internet with an ethernet cable and somehow in th top-right corner it says that is curently connected but when i try to open ice weasel i get a message that tells me “server not found” can someone please tell me how to fix this issue and also i followed your tutorial until the end but i had trouble in the end because i get this message bash: /etc/resolv.conf: no such file or directory . If you can help me i would be so gratefull. Sorry for butchering the english language and its grammar

' src=

Sir, How can we change or spoof dns server in kali Linux.

' src=

I can’t get my static IP address to ping google.

This is what I am trying to do:

ping google.com using a server created with static IP address using Linux Redhat VM Ware,

please help!

' src=

For setting up DHCP using the Command : ifconfig eth0 inet dhcp Also works

For setting up DHCP using command : ifconfig eth0 inet dhcp Also works

Leave your solution or comment to help others. Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed .

Discover more from blackMORE Ops

Subscribe now to keep reading and get access to the full archive.

Type your email…

Continue reading

Privacy Policy on Cookies Usage

Some services used in this site uses cookies to tailor user experience or to show ads.

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

How do you create a new network eth?

I have a machine that has eth0 and eth1, and now I want to create an eth2 and assign it some IP address.

What's the command for doing this?

  • network-adapter
  • redhat-enterprise-linux

fixer1234's user avatar

  • 1 Based on your description I believe this answer will suite your demands better: http://stackoverflow.com/questions/2082722/how-do-i-create-virtual-ethernet-devices-in-linux –  mnmnc Jul 22, 2014 at 23:21

4 Answers 4

On Linux machines, eth0 and eth1 correspond to real network ports. To add an eth2 , you'll need to add another NIC, either by adding an internal PCI(e) network card, or by adding a USB network adapter. See Redhat network interface configuration .

If all you want is another IP address, you can create an ethernet alias on one of your existing adapters. An alias is like a virtual network card -- it lets you assign another IP address to an existing port. Let's assume your eth0 has the IP address 192.168.1.5.

To do this once, run (as root) ifconfig eth0:0 192.168.1.6 up . (Use eth0:1 for a second alias on eth0, eth0:2 for a third, or eth1:0 to alias eth1 instead of eth0.) This configuration will be lost at reboot.

To configure it permanently, add it to a configuration script. Make a copy of /etc/sysconfig/network-scripts/ifcfg-eth0 to the file ifcfg-eth0:0 in the same directory. Change the new file so it looks like this:

The remove or comment out any GATEWAY lines in both files, and add the GATEWAY line to your /etc/sysconfig/network file. Then you can start the new alias with ifup eth0:0 or restart networking entirely with service network restart .

quack quixote's user avatar

  • 1 adding NM_CONTROLLED="no" can help too (rhel6) –  sje397 Nov 30, 2012 at 6:30
  • @sje397 Thanks, mine didn't work until adding this line. –  Kevin Nov 15, 2019 at 19:17

From the way the question is asked it is not clear what is meant when it is said that the machine only has eth0 and eth1 . Other answerers have made an assumption that there are only two NIC cards, but it is also possible that the third NIC is already installed on the compute, but has not been "brought up" (or has been explicitly shut down).

Let us assume that you are sure that you have 3 NIC cards, but somehow when you do ifconfig your output is something along the lines of:

There seems to be a contradiction, you have 3 NIC cards, but only two ports. That is because ifconfig only shows those ports which are "up". So the only thing that you need to do is to run the command:

Keep in mind that it needs to be run as root, do that as is required in your distribution.

You can combine setting the IP address with "bringing the port up":

The "up" should be after other things on this line, but it will still work.

v010dya's user avatar

Follow these steps:

  • Shutdown the computer
  • Disconnect from power
  • Reconnect power
  • Boot computer

random's user avatar

For MAC Monterey open terminal , and from VirtualBox tools networks get the adderess of hostonly interface (my case vboxnet0 has 192.158.66.1)

bortunac's user avatar

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged networking network-adapter redhat-enterprise-linux ..

  • The Overflow Blog
  • How to train your dream machine
  • You should keep a developer’s journal
  • Featured on Meta
  • Our Partnership with OpenAI
  • What deliverables would you like to see out of a working group?

Hot Network Questions

  • Is it an offense to photograph a seahorse?
  • I am a US citizen, my wife is Belgian. We intend to spend 6+ months in Italy. Do I need a visa?
  • Bare Bones – a semi-DIY crossword
  • Indulging your vice when you've got no dice
  • What mistake did Einstein make in 1911 when he miscalculated the light deviation?
  • How to Compute the limit with Integral ?
  • Querying and executing actions on the result C++
  • How to Import MySQL 4.1.14 data into MySQL 5.7.44?
  • Conveying a mathematical joke
  • Is there a problem with having a combined login/register screen?
  • Estimate random effect variance for power analysis in multilevel model
  • Can one tell if a craft is a lifting body or a flying wing just by looking at it?
  • How appreciated is "Part III" in the US?
  • New record for minimally clued 7x7 Hidato (now with 6 clues!)
  • Do I have a cleaner way to assign a parametrized json string to a bash variable?
  • How are quantum systems different from dice?
  • INA125 Reference Voltage lower than expected
  • Why is turing machine considered effective computation if it's not realizable due to bekenstein bound?
  • What would crops and livestock look like if farmers tended to breed the least desirable members of their crops and livestock?
  • Pythagoras' Theorem used to prove a triangle is right angled
  • Scientist swaps body with dictator
  • Older fantasy book series about a boy who trains with a demon to become a wizard
  • Are Eilenberg-MacLane spaces limits of manifolds?
  • Interval exercise gone wrong?

how to assign ip address to eth0 in linux

  • Shell Scripting
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Linux Commands Cheat Sheet
  • Netstat command in Linux
  • What is Network Automation?
  • Linux - Metasploit Command
  • How to Check Network Connectivity in Linux | ping Command
  • Deprecated Linux Networking Commands and Their Replacements
  • nbtstat commnd in Linux
  • How to List Network Interfaces in Linux?
  • Linux Commands
  • Ngrep - Network Packet Analyzer for Linux
  • Top Linux Command Line Tips and Tricks
  • ss command in linux
  • Creating a Simple Chat with netcat in Linux
  • Restart Network on Kali Linux
  • Practical Uses of nc(netcat) command in Linux
  • arp command in Linux with examples
  • Computer Network - Cheat Sheet
  • Network configuration and troubleshooting commands in Linux
  • Nmap Cheat Sheet

Linux Network Commands Cheat Sheet

Linux is a very popular operating system. Many people use it. Developers and network admins need to know Linux network commands well. This article will going explains most of the common Linux network commands in a very easy way and It also has a cheat sheet about these commands. The cheat sheet tells you what each command does and how you use it.

What Are Networking Commands in Linux?

Linux networking commands cheat sheet, network configuration commands, network connectivity commands, dns and name resolution commands, network information commands, network testing and monitoring commands, network analysis and monitoring commands, remote access commands, security commands, utility commands.

Networking commands in Linux allow users to manage network connections. These commands let users set up networks, fix connection issues, and view network traffic. Users can also check network status, change settings, and control network programs with these commands. The commands use basic words that are easy for beginners to understand.

This list of Linux networking commands will help you work with network connections. You can use these commands to set up the networks, fix connection problems, and see the information about the network. If you are an experienced network admin or just starting to learn the Linux networking commands this command list will be a useful tool for you.

In summary, this shows important Linux commands for working with networks. These commands help you see and fix network problems. The commands let you check network traffic, bandwidth usage, security issues, and more. Beginners may gonna find this network commands list very helpful for learning the Linux networking basics.

Linux Network Commands Cheat Sheet – FAQs

How can i check if my internet connection is working on the linux.

The “ping” command is use to test if you can reach the website or the server. For example “ping www.google.com” will send the data packets and it will show if the connection is successful or not.

How do I find out my computers IP address on the Linux?

The “ip addr show” or “ifconfig” command is use to display the information about the your network interfaces including the IP addresses that are assigned to them.

I am having the trouble connecting to the WiFi network. What Linux command will help me?

The “iwconfig” command is allows you to view and configure the wireless network interfaces. You can use it to scan for the available networks connect to the specific network and troubleshoot the issues.

How can I see that what other devices or computers are connected to the my local network?

The “arp -a” command will used to display the ARP (Address Resolution Protocol) table which will maps the IP addresses to the MAC addresses for the devices onto the your local network.

My internet is really slow. Is there a command to check my network bandwidth usage?

Yes The “iftop” or “bwm-ng” commands is use to show you the bandwidth being used by the different connections or the applications in the real time.

Please Login to comment...

Similar reads.

author

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

How can I (from CLI) assign multiple IP addresses to one interface?

On my server I want to assign several IP addresses to one NIC, but without using the deprecated ifconfig or the obsolete "alias" notation (like eth0:0 ) in /etc/network/interfaces because in IP Aliasing (on www.kernel.org) you can read

IP-aliases are an obsolete way to manage multiple IP-addresses/masks per interface
  • command-line

guntbert's user avatar

  • ifconfig is deprecated? I didn't know. –  Mahesh Nov 8, 2014 at 18:53
  • @Mahesh Yeah, ifconfig is an artifact from the SysV era. 'iproute2' is the more modern tool. ifconfig will be around for a while on various distros, but yeah, it's deprecated; "deprecated" is just a colloquialism we used to denote "look for something newer to use". –  David Betz Jan 4, 2016 at 16:16

3 Answers 3

If you need an additional IP address just for the moment you can add it to any interface on your machine with

for instance

would add 172.16.100.17 using a 24 bit network prefix to the list of addresses configured for your eth0 .

You can check the result with

and you can delete this address again with

Of course these changes are lost when you reboot your machine.

To make the additional addresses permanent you can edit the file /etc/network/interfaces by adding as many stanzas of the form

so that it looks like

You can even keep the dhcp for the primary address.

To activate these settings without a reboot use ifdown/ifup like

It is essential to put those two commands into one line if you are remoting into the server because the first one will drop your connection! Given in this way the ssh-session will survive.

balazer's user avatar

  • You can maybe make an vpn whit more then one ip address by installing from from software manager. –  Michael Nov 8, 2014 at 19:23
  • No reboot is required on Ubuntu 16.04.3 LTS after adding or deleting an IP –  Daniel F Nov 9, 2017 at 17:55
  • 2 looks like ifdown is deprecated in newer Ubuntu versions. –  Sajuuk Jun 10, 2018 at 4:29

With the new toolkit, it is as easy as with the old to add new ip addresses:

When looking with ip addr show again, you see the second ip address assigned to the interface:

Remove that ip address with:

The iproute2 suite:

The iproute2 suite is the communication suite for interprocess communication beween the kernel and the user space via the netlink protocol. It should replace the whole standard network tools. Here is what they replace:

  • ifconfig --> ip addr and ip link
  • route --> ip route
  • arp --> ip neigh
  • iptunnel --> ip tunnel
  • ipmaddr --> ip maddr
  • netstat --> ss

Craig S. Anderson's user avatar

  • Thx for providing the matching commands. –  guntbert Nov 8, 2014 at 19:19
  • thx @chaos, well can I have more ip's than my no of interfaces on my system?? –  lazarus Nov 9, 2014 at 12:29
  • @jazzz yes, as you can see in the output of my interface above, there are 2 ip addresses assigned to it (192.168.0.100 and 192.168.1.1). You can add another one if you wish. –  chaos Nov 9, 2014 at 13:33
  • @chaos, but how can I use them, for an instance I want to create a group for multicasting,,can I form a group from them,, can you please refer to my question askubuntu.com/questions/547105/… –  lazarus Nov 9, 2014 at 14:29
  • 2 @chaos I am accepting my own answer instead of your excellent one because yours lacks the "permanency" which I expect on a server config. –  guntbert Feb 3, 2015 at 21:33

One way is:

Bert's user avatar

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged networking command-line ip-address ..

  • The Overflow Blog
  • How to train your dream machine
  • You should keep a developer’s journal
  • Featured on Meta
  • Our Partnership with OpenAI
  • What deliverables would you like to see out of a working group?

Hot Network Questions

  • Should I remove a reference after applying to job?
  • Is there any object we own but don't possess?
  • How is the Kohen allowed to reply "Bruchim Tihyu" after Birchas Kohanim?
  • Can one tell if a craft is a lifting body or a flying wing just by looking at it?
  • Do I have a cleaner way to assign a parametrized json string to a bash variable?
  • Cold Bee and Old Beer
  • Conveying a mathematical joke
  • How is the international community compensating for the May, 2024 Egyptian withdrawal of cooperation regarding aid to Gaza?
  • Strange spacing behavior with libertinust1math font and integral sign. Is this a bug?
  • Solana address length
  • Why did the Iranian president use an old American helicopter?
  • Warning: this puzzle contains made-up words
  • How to make a sphere from many small spheres
  • Who says understanding physics helps mathematicians? (A reference request) [Take the word "who" literally.]
  • What is the difference in the usage of the verbs "lernen" and "studieren"?
  • Indulging your vice when you've got no dice
  • What would crops and livestock look like if farmers tended to breed the least desirable members of their crops and livestock?
  • How to create a crossword based on a 16 letter theme
  • The static keyword and clarity in language design
  • What is the fastest static comparison sort? What is the proper term for "static"?
  • How are quantum systems different from dice?
  • Interval exercise gone wrong?
  • Should I wait to send a revised manuscript?
  • 6-functor formalism for topological stacks

how to assign ip address to eth0 in linux

TecAdmin

How to Configure Static IP Address on Ubuntu 24.04

The Ubuntu team has once again kept their promise and released a new long-term support version, Ubuntu 24.04 (Noble Numbat), which comes with many great features. After installing it, setting up the network interface is an important first step for users. Usually, the system automatically gets an IP address from DHCP, but sometimes you might need to set up a static IP address. A static IP address does not change even when the system restarts, which is very helpful for managing networks and running servers.

This guide will show you how to set up a static IP address on Ubuntu 24.04, whether you are using the desktop environment or managing servers using the command line.

Introduction

A static IP address is set up manually on a computer to make sure it stays the same, unlike dynamic IP addresses that a DHCP server assigns and can change. Static IPs are commonly used for servers, network printers, and other devices that need to be consistently reachable over the network.

Requirements

  • A machine running Ubuntu 24.04 (Noble Numbat).
  • Basic familiarity with the system’s terminal and network configuration files.
  • Administrative (sudo) privileges.

Setting Up a Static IP in Ubuntu 24.04 Desktop Environment

Ubuntu 24.04 continues to use GNOME as its default desktop environment, which provides an intuitive interface for managing network settings. Follow the below steps to configure static IP address on your Ubuntu desktop system.

Step 1: Access Network Settings

  • Click on the icons at the top right corner of the screen.

Setting Up IP Address on Ubuntu 24.04

Step 2: Configure IP address

  • In the settings menu, go to the IPv4 tab.
  • Toggle the IPv4 Method to Manual.
  • Enter your desired IP address, netmask (often 255.255.255.0), and gateway.
  • Add DNS servers if necessary.

Setting Up IP Address on Ubuntu 24.04

Step 3: Apply Configuration

Click Apply button to save your settings. This will automatically update your system ip address. Wait for a to apply the changes. Then you can check updated IP address in details tab.

Setting Up a Static IP in Ubuntu 24.04 using Command Line Interface

If you like using the command line or need to set up a server without a graphical interface, the command line method is easy and effective.

Step 1: Open Terminal

You can open the terminal by pressing Ctrl + Alt + T or by looking for ‘Terminal’ in the applications menu.

Step 2: Identify Your Network Interface

Type the command ip link to see all network interfaces.

Find the interface you want to set up, like eth0 for a wired connection or wlan0 for wireless.

Step 3: Edit Netplan Configuration

Ubuntu 24.04 uses Netplan to manage network settings. Find the Netplan configuration files in /etc/netplan/. Open a file with a text editor, for example, type:

Step 4: Configure Static IP

Change the file to add your static IP details. For instance:

Switch eth0 with your network interface and adjust the IP settings as needed.

Step 5: Apply Changes

Save the file and update the changes with sudo netplan apply.

Check the new settings with ip addr show or by pinging another device.

Whether you like a graphical interface or the command line, setting up a static IP address in Ubuntu 24.04 (Noble Numbat) is easy. This setup can make your network more reliable and easier to access. Always test your settings to make sure the network works as you expect.

Related Posts

How to setup openssh server on ubuntu 24.04, running a local shell script on a remote server using ssh, autossh – setting up persistent ssh connections.

Save my name, email, and website in this browser for the next time I comment.

Type above and press Enter to search. Press Esc to cancel.

  • Programming

#NetworkProtocol

#packetprocessing, exploring linux network protocols for better packet processing.

Exploring Linux Network Protocols for Better Packet Processing

Introduction

In the realm of modern computing, networking is a cornerstone that facilitates communication between devices and systems. Among the various operating systems, Linux stands out for its robustness and versatility in handling network operations. This article aims to provide an understanding of Linux network protocols and packet processing, offering insights that are crucial for both novice and seasoned network administrators.

Overview of Network Protocols

Network protocols are formal standards and policies consisting of rules, procedures, and formats that define how data is exchanged over networks. They ensure that devices can communicate effectively, regardless of their underlying architecture or design. Without these protocols, the seamless exchange of information across the vast and diverse landscape of the internet would be impossible.

TCP/IP Suite:

  • Transmission Control Protocol (TCP): TCP is a connection-oriented protocol that ensures reliable data transmission between devices. It breaks down data into packets, ensures their delivery, and reassembles them at the destination.
  • Internet Protocol (IP): IP is responsible for addressing and routing packets of data so that they can travel across networks and arrive at the correct destination.
  • User Datagram Protocol (UDP): UDP is a connectionless protocol that allows for faster data transmission at the expense of reliability. It is used in scenarios where speed is critical, such as video streaming or online gaming.

Application Layer Protocols:

  • HTTP/HTTPS: These protocols are the foundation of data communication on the World Wide Web. HTTPS is the secure version of HTTP.
  • FTP: The File Transfer Protocol is used for transferring files between a client and a server on a network.
  • SSH: Secure Shell provides a secure channel over an unsecured network in a client-server architecture.

Other Important Protocols:

  • ICMP: The Internet Control Message Protocol is used for sending error messages and operational information, such as the well-known ping command.
  • ARP: The Address Resolution Protocol maps IP addresses to physical MAC addresses, which is crucial for packet delivery in local networks.
  • DHCP: The Dynamic Host Configuration Protocol dynamically assigns IP addresses to devices on a network, ensuring efficient IP management.

Understanding the OSI Model

The OSI (Open Systems Interconnection) model is a conceptual framework used to understand network interactions in seven distinct layers:

  • Physical Layer: Deals with the physical connection between devices, including cables, switches, and other hardware.
  • Data Link Layer: Manages the data transfer between two directly connected nodes, including error detection and MAC addressing.
  • Network Layer: Handles routing of data packets across networks and includes protocols like IP.
  • Transport Layer: Ensures reliable data transfer and includes protocols like TCP and UDP.
  • Session Layer: Manages sessions between applications, including setting up, managing, and terminating connections.
  • Presentation Layer: Translates data between the application layer and the network, handling encryption and compression.
  • Application Layer: Interfaces directly with end-user applications and facilitates network services like email, file transfer, and web browsing.

In Linux, networking components map to various layers of the OSI model:

  • Physical and Data Link Layers: Handled by network interfaces and device drivers.
  • Network Layer: Managed by the kernel’s IP stack.
  • Transport Layer: Managed by protocols like TCP and UDP within the kernel.
  • Application Layer: Handled by user-space applications like web browsers, email clients, and network utilities.

Linux Networking Stack

In Linux, network operations are divided between kernel space and user space:

  • Kernel Space: The kernel handles low-level networking functions such as packet routing, firewall rules, and network interface control. This space provides the necessary performance and security.
  • User Space: Applications running in user space utilize system calls to interact with the network stack. This division ensures stability, as user-space errors do not crash the system.
  • Network Interfaces: These are the physical or virtual interfaces that connect the Linux system to a network. Examples include Ethernet (eth0), Wi-Fi (wlan0), and loopback (lo).
  • Protocol Handlers: The kernel uses protocol handlers to process different network protocols. For example, tcp_v4_rcv handles incoming TCP packets.
  • Sockets: Sockets provide a mechanism for applications to send and receive data over the network. They are endpoints for communication defined by IP address and port number.

Packet Processing in Linux

Packet flow in Linux starts from the network interface card (NIC) and travels through various layers of the kernel before reaching user-space applications or being transmitted out. Understanding this flow is essential for network troubleshooting and optimization.

  • Network Interface Card (NIC): The NIC receives incoming packets from the physical network medium and transfers them to the system memory.
  • Interrupt Handling: The NIC generates an interrupt to notify the CPU of incoming packets. The CPU processes these interrupts promptly to ensure minimal packet loss.
  • Network Drivers: These drivers manage the interaction between the NIC and the operating system, ensuring packets are correctly passed to the network stack.
  • Netfilter Framework: Netfilter is a powerful framework within the Linux kernel that provides various functions for packet filtering, NAT, and packet mangling. It is the backbone of tools like iptables.
  • Routing and Forwarding: The kernel decides the packet's route based on the routing table. It either forwards the packet to the correct network interface or passes it to a local process.
  • NAT (Network Address Translation): NAT modifies packet headers to translate between private and public IP addresses, allowing multiple devices to share a single public IP.
  • Steps Involved in Packet Transmission: The packet flow for outgoing packets includes checking routing tables, applying firewall rules, and queuing the packet for transmission.
  • Queuing and Scheduling: The kernel uses queuing disciplines (qdiscs) to manage packet transmission, ensuring fair bandwidth distribution and prioritization.

Tools for Analyzing Network Traffic

  • tcpdump: A command-line packet analyzer that allows users to capture and analyze network traffic in real time. It provides detailed insights into network operations.
  • Wireshark: A graphical tool for network protocol analysis. It offers comprehensive features for deep inspection of hundreds of protocols and is widely used for troubleshooting and educational purposes.
  • netstat: Provides statistics on network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
  • iftop: Displays bandwidth usage on an interface by host, showing a real-time overview of network traffic.
  • iperf: A tool for measuring network bandwidth and quality. It is useful for testing the maximum bandwidth between two hosts.

Common Network Configuration Commands

  • ifconfig: An older tool for configuring network interfaces. It can display interface configurations, assign IP addresses, and manage other interface settings.
  • ip: A newer, more powerful tool for network configuration. It is part of the iproute2 suite and provides extensive capabilities for managing interfaces, routing, and tunnels.
  • route: Displays and manipulates the IP routing table. It allows users to add or delete static routes.
  • ip route: Provides advanced routing capabilities and is preferred over the older route command for managing routing tables.
  • iptables: A user-space utility to configure the Linux kernel firewall implemented by Netfilter. It allows users to define rules for packet filtering, NAT, and packet mangling.

Practical Examples

  • Setting Up IP Addresses: sudo ip addr add 192.168.1.10/24 dev eth0 sudo ip link set eth0 up
  • Basic Routing Configuration: sudo ip route add default via 192.168.1.1
  • Using ping to Check Connectivity: ping 8.8.8.8

traceroute www.google.com

  • Checking Interface Statistics with ifconfig or ip : ifconfig eth0 ip -s link show eth0

Understanding network protocols and packet processing in Linux is vital for system administrators and network engineers. By mastering these concepts, professionals can effectively manage, troubleshoot, and optimize network operations. This guide has provided an overview, from fundamental protocols and the OSI model to the intricacies of Linux's networking stack and packet processing. For those eager to deepen their knowledge, practical experience and further study are highly encouraged.

how to assign ip address to eth0 in linux

George Whittaker is the editor of Linux Journal, and also a regular contributor. George has been writing about technology for two decades, and has been a Linux user for over 15 years. In his free time he enjoys programming, reading, and gaming.

Firstwave Cloud

Recent Articles

Exploring Linux Network Protocols for Better Packet Processing

Multicast Forwarding in Linux

Multicast Forwarding from eth0 to tun0 in Linux: A Step-by-Step Guide

Abstract: Learn how to forward multicast packets from eth0 to tun0 in Linux, enabling multicast communication between networks.

Multicast Forwarding from eth0 to tun0 on Linux: A Step-by-Step Guide

In this article, we will discuss the steps required to forward multicast packets from eth0 to tun0 on a Linux system. This can be useful in scenarios where a PC is connected directly to a network cable and needs to send multicast packets to a tun0 interface.

Prerequisites

  • A Linux system with two network interfaces: eth0 and tun0
  • A network cable connection to the Linux system
  • Root or sudo access to the Linux system

Step 1: Configure the tun0 Interface

Before we can forward multicast packets from eth0 to tun0, we need to ensure that the tun0 interface is properly configured. This can be done using the following steps:

  • Create a new tap device using the following command:

Replace with your username on the system.

  • Bring up the tun0 interface using the following command:
  • Set the IP address and netmask of the tun0 interface using the following commands:

Replace and with the desired IP address and netmask for the tun0 interface.

Step 2: Configure IP Multicast on the eth0 Interface

Once the tun0 interface is properly configured, we need to enable IP multicast on the eth0 interface. This can be done using the following steps:

  • Add the following line to the /etc/sysctl.conf file to enable IP multicast:
  • Load the new sysctl settings using the following command:
  • Add the following line to the /etc/rc.local file to enable IP multicast on boot:

Step 3: Configure Multicast Routing

Now that IP multicast is enabled on both the eth0 and tun0 interfaces, we need to configure multicast routing between them. This can be done using the following steps:

  • Install the iproute2 package using the following command:
  • Add the following line to the /etc/iproute2/rt_tables file to create a new routing table:
  • Add the following route to the new routing table using the following command:

Replace with the multicast address that you want to forward to the tun0 interface.

  • Add the following rule to the main routing table using the following command:
  • Add the following route to the main routing table using the following command:

Replace with the IP address of the default gateway on the network.

Step 4: Test Multicast Forwarding

To test multicast forwarding from eth0 to tun0, we can use the following command:

This command will start forwarding multicast packets from the eth0 interface to the tun0 interface.

In this article, we have discussed the steps required to forward multicast packets from eth0 to tun0 on a Linux system. This can be useful in scenarios where a PC is connected directly to a network cable and needs to send multicast packets to a tun0 interface.

  • tunctl man page
  • ip man page
  • setip man page

Dive deeper into multicast forwarding in Linux by following this simple guide. Set up your Linux system to send multicast packets from eth0 to tun0.

Creating gltf models for web-xr: a step-by-step guide.

Learn how to create and use GLTF models in Web-XR applications. Follow this guide to understand the process and get started.

Solving Compile Errors in Shared .NET Standard Projects with NuGet 6 and Central Project Management

In this article, we explore how to solve compile errors in shared .NET Standard projects using NuGet 6 and Central Project Management (CPM). We'll walk through the steps to upgrade a solution to use CPM, go back to the previous solution, and compile the project.

Tags: :  Linux Networking Multicast

Latest news

  • Understanding SSL.LoadClientCertAsync and SSL.ClientCertificateErrors in ASP.NET Core
  • Inconsistent Behavior When Calling Console Application from ASP.NET Web Application
  • Making Calendar Functionality Mark Working Days: A Step-by-Step Guide
  • PostgreSQL Stopped Using Index for Large Queries: Troubleshooting
  • Reddit API Authentication Failed: Building NLP Project
  • Troubleshooting Symfony 404 Error with New Routes
  • Sending Email via .NET with EWS using Logged-in User's Credentials: Automate Email Processes in Outlook
  • Revamped CTRL-T (Go) Dialog in Visual Studio 2022 17.10
  • Managing Hotel Reservation Inquiries with Django: Handling Email Requests via Django-Mailbox
  • Understanding Asynchronous Functions in Delphi: A Simple Example
  • Making a Form Field Random Number Generator Button Disappear After Click
  • Removing Last Parentheses String Contents in Python using Regex
  • User Auth without Sign-In: Implementing Wallet Connect in a Crypto Site
  • Azure Data Factory Managed Instance: Error Connecting to JSON Data Flow
  • Kivy AdMob Ads Don't Appear on Android Device or Emulator
  • Google OAuth Verification Accepted but Users Still Blocked: A Solution
  • Understanding Template Parameters in C++: An Example with MCFLemonSolver
  • Connecting to IBM MQ with .NET 8 and IBMMQ.DotnetClient: A Local Docker Setup
  • Troubleshooting Slow-Loading Programs on Your PC
  • Editing Multiple Text Files with Notepad++: Adding Lines Beginning with Certain Word in Music Lyric Files
  • ML Training on Pump Sensor Data: Recursion Error in Jupyter Notebook
  • Azure DNS: Creating TXT Records for Domain Ownership Validation using Azure REST API
  • Understanding Line Code Not Recognizing Data: A Common Software Development Challenge
  • Resolving TypeError in Wilberforce Pendulum Python Project for Classical Mechanics
  • Member Variable Set to Wrong Value in OpenGL Model Loading Functionality
  • Understanding the Difference: OverrideCursor vs. SetCursor in Software Development
  • Impersonating a Windows Identity with Constructed User Principal Name
  • VB.Net MicroStation: Why Won't the PathToScan TextField Update Programmatically?
  • Understanding Errors with 'default' Ranges in Helm: Deploying CronJobs
  • Running a Termux Command in Another App: Build Script for Java
  • Troubleshooting GitHub Push Code: VSCode vs. Code Spaces
  • Custom CodeQL Query in Azure DevOps YAML pipeline gives error: 'No queries defined' (JavaScript)
  • Apache Beam: Illegal Mutation Exception when Modifying Original Input
  • Implementing TimedRotatingFileHandler for Thread-Safe High Concurrency Environments in Python APIs using FastAPI and Gunicorn
  • Running .NET 6 System Tests with GitHub Actions: dotnet run dotnettest
  • NVIDIA Cumulus Linux
  • NVIDIA NetQ
  • NVIDIA Cumulus VX
  • Knowledge Base
  • Technical Guides

Cumulus Linux

Quick Start Guide

This quick start guide provides an end-to-end setup process for installing and running Cumulus Linux.

Prerequisites

This guide assumes you have intermediate-level Linux knowledge. You need to be familiar with basic text editing, Unix file permissions, and process monitoring. Cumulus Linux includes a variety of preinstalled text editors, such as vi and nano .

You must have access to a Linux or UNIX shell. If you are running Windows, use a Linux environment like Cygwin as your command line tool for interacting with Cumulus Linux.

Get Started

Cumulus Linux is on the switch by default. To upgrade to a different Cumulus Linux release or reinstall Cumulus Linux, refer to Installation Management . To show the current Cumulus Linux release on the switch, run the NVUE nv show system command.

When starting Cumulus Linux for the first time, the management port makes a DHCPv4 request. To determine the IP address of the switch, you can cross reference the MAC address of the switch with your DHCP server. The MAC address is typically located on the side of the switch or on the box in which the unit ships.

To get started:

  • Log in to Cumulus Linux on the switch and change the default credentials.
  • Configure Cumulus Linux. This quick start guide provides instructions on changing the hostname of the switch, setting the date and time, and configuring switch ports and a loopback interface.

You can choose to configure Cumulus Linux either with NVUE commands or Linux commands (with vtysh or by manually editing configuration files). Do not run both NVUE configuration commands (such as nv set , nv unset , nv action , nv config ) and Linux commands to configure the switch. NVUE commands replace the configuration in files such as /etc/network/interfaces and /etc/frr/frr.conf , and remove any configuration you add manually or with automation tools like Ansible, Chef, or Puppet.

If you choose to configure Cumulus Linux with NVUE, you can configure features that do not yet support the NVUE object model by creating NVUE Snippets .

Login Credentials

The default installation includes two accounts:

  • The system account (root) has full system privileges. Cumulus Linux locks the root account password, which prohibits login.
  • The user account (cumulus) has sudo privileges. The cumulus account uses the default password cumulus . When you log in for the first time with the cumulus account, Cumulus Linux prompts you to change the default password. After you provide a new password, the SSH session disconnects and you have to reconnect with the new password.

ONIE includes options that allow you to change the default password for the cumulus account automatically when you install a new Cumulus Linux image. Refer to ONIE Installation Options . You can also change the default password using a ZTP script .

In this quick start guide, you use the cumulus account to configure Cumulus Linux.

All accounts except root can use remote SSH login; you can use sudo to grant a non-root account root-level access. Commands that change the system configuration require this elevated level of access.

For more information about sudo , see Using sudo to Delegate Privileges .

Serial Console Management

NVIDIA recommends you perform management and configuration over the network, either in band or out of band. A serial console is fully supported.

Typically, switches ship from the manufacturer with a mating DB9 serial cable. Switches with ONIE are always set to a 115200 baud rate.

Wired Ethernet Management

A Cumulus Linux switch always provides at least one dedicated Ethernet management port called eth0. This interface is specifically for out-of-band management use. The management interface uses DHCPv4 for addressing by default.

To set a static IP address and gateway address for eth0:

Edit the /etc/network/interfaces file:

Configure the Hostname

The hostname identifies the switch; make sure you configure the hostname to be unique and descriptive.

Do not use an underscore (_), apostrophe ('), or non-ASCII characters in the hostname.

To change the hostname:

Change the hostname with the hostnamectl command; for example:

In the /etc/hosts file, replace the host for IP address 127.0.1.1 with the new hostname:

The command prompt in the terminal does not reflect the new hostname until you either log out of the switch or start a new shell.

Configure the Time Zone

The default time zone on the switch is UTC (Coordinated Universal Time). Change the time zone on your switch to be the time zone for your location.

To update the time zone:

Run the nv set system timezone <timezone> command. To see all the available time zones, run nv set system timezone and press the Tab key. The following example sets the time zone to US/Eastern:

In a terminal, run the following command:

Follow the on screen menu options to select the geographic area and region.

Programs that are already running (including log files) and logged in users, do not see time zone changes. To set the time zone for all services and daemons, reboot the switch.

Verify the System Time

Verify that the date and time on the switch are correct. If the date and time are incorrect, the switch does not synchronize with automation tools, such as Puppet, and returns errors after you restart switchd .

To show the current date and time, run the nv show system date-time command:

To set the software clock according to the configured time zone, run the nv action change system date-time <YYYY-MM-DD> <HH:MM:SS> command; for example:

To show the current date and time on the switch, run the date command:

To set the software clock according to the configured time zone, run the sudo date -s command:

For more information about setting the system time, see Setting the Date and Time .

NTP and PTP

  • NTP starts at boot by default on the switch and the NTP configuration includes default servers. To customize NTP, see NTP .
  • PTP is off by default on the switch. To configure PTP, see PTP .

Configure Breakout Ports with Splitter Cables

If you are using 4x10G DAC or AOC cables, or you want to break out (split) switch ports, configure the breakout ports; see Switch Port Attributes .

Test Cable Connectivity

By default, Cumulus Linux disables all data plane ports (every Ethernet port except the management interface, eth0). To test cable connectivity, administratively enable physical ports.

To enable a port administratively, run the nv set interface <interface> command:

To enable all physical ports administratively on a switch that has ports numbered from swp1 to swp52:

To view link status, run the nv show interface command.

To enable a port administratively:

To enable all physical ports administratively, run the following bash script:

To view link status, run the ip link show command.

Configure Layer 2 Ports

Cumulus Linux does not put all ports into a bridge by default. To create a bridge and configure one or more front panel ports as members of the bridge:

The following configuration example places the front panel port swp1 into the default bridge called br_default .

You can add a range of ports in one command. For example, to add swp1 through swp3, swp10, and swp14 through swp20 to the bridge:

The following configuration example places the front panel port swp1 into the default bridge called br_default :

To put a range of ports into a bridge, use the glob keyword. For example, to add swp1 through swp10, swp12, and swp14 through swp20 to the bridge called br_default :

To apply the configuration, check for typos:

If there are no errors, run the following command:

For more information about Ethernet bridges, see Ethernet Bridging - VLANs .

Configure Layer 3 Ports

You can configure a front panel port or bridge interface as a layer 3 port.

The following configuration example configures the front panel port swp1 as a layer 3 access port:

To add an IP address to a bridge interface, you must put it into a VLAN interface. If you want to use a VLAN other than the native one, set the bridge PVID:

To add an IP address to a bridge interface, include the address under the iface stanza in the /etc/network/interfaces file. If you want to use a VLAN other than the native one, set the bridge PVID:

Configure a Loopback Interface

Cumulus Linux has a preconfigured loopback interface. When the switch boots up, the loopback interface, called lo , is up and assigned an IP address of 127.0.0.1.

The loopback interface lo must always exist on the switch and must always be up. To check the status of the loopback interface, run the NVUE nv show interface lo command or the Linux ip addr show lo command.

To add an IP address to a loopback interface, configure the lo interface:

Add the IP address directly under the iface lo inet loopback definition in the /etc network/interfaces file:

If you configure an IP address without a subnet mask, it becomes a /32 IP address. For example, 10.10.10.1 is 10.10.10.1/32.

You can add multiple loopback addresses. For more information, see Interface Configuration and Management .

Show Platform and System Settings

  • To show the hostname of the switch, the time zone, and the version of Cumulus Linux running on the switch, run the NVUE nv show system command.
  • To show switch platform information, such as the system MAC address, manufacturer, ASIC model, CPU, hard disk drive size, RAM size, and port layout, run the NVUE nv show platform command.

You are now ready to configure the switch according to your needs. This guide provides separate sections that describe how to configure system , layer 1 , layer 2 , layer 3 , and network virtualization settings. Each section includes example configurations and pre-built demos .

For a deep dive into the NVUE object model that provides a CLI to simplify configuration, see NVUE .

Copyright © 2024  NVIDIA Corporation

  • Privacy Policy |
  • Manage My Privacy |
  • Do Not Sell or Share My Data |
  • Terms of Service |
  • Accessibility |
  • Corporate Policies |
  • Product Security |

COMMENTS

  1. How to Change IP Address in Linux

    For example, add an IP address to the eth1 interface as: sudo ip addr add 192.168.56.21/24 dev eth1. You now have two IP addresses: one from the old configuration and one from the new command: Changing IP address in Linux. As you can see in the above screenshot, after deleting the old one, you are left with only one. Making an IP Address Permanent

  2. networking

    auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.20.20 netmask 255.255.255. network 192.168.20. broadcast 192.168.20.255 gateway 192.168.20.250 The first two lines are standard and may already look similar on your box.

  3. How to Find out the IP address assigned to eth0 and display IP only

    Using hostname and ip command for finding out the IP address assigned to eth0. The syntax is as follows to display the network address (es) of the host name using the hostname command: $ hostname -i. We can also use the following option to find out all network IP addresses of the host.

  4. Linux ip Command with Examples

    For example, to bring the interface eth0 online, you would type:. ip link set eth0 up. And to bring if offline. ip link set eth0 down Displaying and Altering the Routing Table #. To assign, remove, and display the kernel routing table use the route object. The most commonly used commands when working with the routes objects are: list, add, and del. Display routing table #

  5. Linux ifconfig Command

    With the ifconfig command, you can assign an IP address and netmask to a network interface. Use the following syntax to assign the IP address and netmask: ifconfig [interface-name] [ip-address] netmask [subnet-mask] For example, to assign the IP address 192.168..101 and netmask 255.255.. to the interface eth0, you would run:

  6. Understanding and Configuring Linux Network Interfaces

    In short, we assign a special IP address (127.0.0.1). Here's the format for the declaration of an interface: iface <interface> <address_family> <method> For example, we could declare an interface eth0 and get an IP address dynamically using DHCP: iface eth0 inet dhcp. To configure an interface statically, we follow these steps.

  7. Manual Network Configuration in Linux and How to Set a Static IP Address

    In this tutorial, we look at standard low-level files and tools to configure our IP address settings. We start off by briefly discussing dynamic and static addresses. After picking static IP network configuration as an example, we look at a universal way to perform it under Linux. Next, we explore network managers in detail.

  8. How to Assign an IP Address on a Linux Computer (with Pictures)

    Change the item's IP address. Type in sudo ifconfig name ipaddress netmask 255.255.255. up—making sure to replace name with your item's name and ipaddress with your preferred IP address—and press ↵ Enter.. To assign an IP of "192.168.2.100" to your ethernet connection ("eth0"), for example, you'd enter sudo ifconfig eth0 192.168..100 netmask 255.255.255. here.

  9. How to Use the ip Command on Linux

    The ip command has replaced the older ifconfig command in modern versions of Linux. The ip command allows you to configure IP addresses, network interfaces, and routing rules on the fly without rebooting. Run "ip addr" in the Terminal to get your PC's local IP address. You can configure IP addresses, network interfaces, and routing rules on the ...

  10. Linux ip Command Examples

    The ip command is used to assign an address to a network interface and/or configure network interface parameters on Linux operating systems. This command replaces old good and now deprecated ifconfig command on modern Linux distributions. ... # ip route del 192.168.1./24 dev eth0. How to change MAC address on Linux. The MAC address of a Linux ...

  11. 15 Useful "ifconfig" Commands to Configure Network in Linux

    1. List Network Interfaces in Linux. The " ifconfig " command with no arguments will display all the active network interface configuration details that includes their assigned IP addresses, netmasks, and other relevant information. $ ifconfig. Sample Output: eth0 Link encap:Ethernet HWaddr 00:0B:CD:1C:18:5A.

  12. How to Change Your IP Address From the Command Line in Linux

    To get started, type. ifconfig. at the terminal prompt, and then hit Enter. This command lists all network interfaces on the system, so take note of the name of the interface for which you want to change the IP address. To change the settings, you also use the ifconfig command, this time with a few additional parameters.

  13. How to Configure Static IP Address on Ubuntu 20.04

    Depending on the interface you want to modify, click either on the Network or Wi-Fi tab. To open the interface settings, click on the cog icon next to the interface name. In "IPV4" Method" tab, select "Manual" and enter your static IP address, Netmask and Gateway. Once done, click on the "Apply" button.

  14. ip

    If your dhcp is properly configured to give you an IP address, the command: dhclient eth0 -v. should work. The option -v enable verbose log messages, it can be useful. If your eth0 is already up, before asking for a new IP address, try to deconfigure eth0. To configure the network interfaces based on interface definitions in the file /etc ...

  15. How to Set Static IP Address and Configure Network in Linux

    @Thuemaychuaonet, If your server is connected only via WiFi, the network interface will likely have a different name, such as `wlan0` or something similar, depending on your system and its configuration. The steps to set a static IP address and configure the network are similar, but you'll need to use the correct interface name for your WiFi connection.

  16. 3 Ways to change ip address in Linux

    Open the terminal application. List the current IP addresses for all network interfaces with command ifconfig -a. Take the network interface down with command: ifconfig <interface> down. Change the IP address with command ifconfig <interface> <ip address> <netmask>. Press Enter to run the command.

  17. How To Change IP Address on Linux

    To change your IP address on Linux, use the "ifconfig" command followed by the name of your network interface and the new IP address to be changed on your computer. To assign the subnet mask, you can either add a "netmask" clause followed by the subnet mask or use the CIDR notation directly.

  18. Linux Ip Command: An Ultimate Guide With Practical Examples

    It allows network administrators to configure network interfaces, assign IP addresses, and set up routing. The ip command is a relatively recent networking command-line utility for assigning IP addresses and modifying network variables on Linux systems. Before the introduction of ip, Linux relied on the ifconfig command for similar functionalities.

  19. How to configure a static IP address on CentOS 7 / RHEL 7

    Verify new IP settings using the ip command for the NIC named eth0: # ip a s eth0 Verify new routing settings: # ip r Next, verify DNS servers settings using the cat command or grep command to query the /etc/resolv.conf file as follows: # cat /etc/resolv.conf Finally verify the internet connectivity using the ping command: # ping -c 3 cyberciti ...

  20. Setup DHCP or static IP address from command line in Linux

    # ifconfig eth0 up (or) # ifup eth0. With DHCP, you get IP address, subnet mask, broadcast address, Gateway IP and DNS ip addresses. Go to step xxx to test your internet connection. Step 4.2 - Setup static IP, subnet mask, broadcast address in Linux. Use the following command to setup IP, subnet mask, broadcast address in Linux.

  21. networking

    On Linux machines, eth0 and eth1 correspond to real network ports. To add an eth2, you'll need to add another NIC, either by adding an internal PCI(e) network card, or by adding a USB network adapter.See Redhat network interface configuration.. If all you want is another IP address, you can create an ethernet alias on one of your existing adapters. An alias is like a virtual network card -- it ...

  22. Linux Network Commands Cheat Sheet

    ifup eth0. Activates the eth0 network interface. ifdown. Deactivates a network interface that is currently active or up. ifdown wlan0. Deactivates the wlan0 wireless interface. dhcclient. Automatically gets an IP address and other network configuration details from a DHCP server. dhclient eth0. Requests an IP address for the eth0 interface from ...

  23. How can I (from CLI) assign multiple IP addresses to one interface?

    With the new toolkit, it is as easy as with the old to add new ip addresses: ip addr add 192.168.1.1/24 dev eth0. When looking with ip addr show again, you see the second ip address assigned to the interface: 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000. link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff.

  24. How to Configure Static IP Address on Ubuntu 24.04

    Step 1: Access Network Settings. Click on the icons at the top right corner of the screen. Click the > icon next to Wired or Wireless connection. Click the (Wired) Settings option as shown in screenshot. This will show you the current IP address with other network details. Click the gear icon in front of them:

  25. Exploring Linux Network Protocols for Better Packet Processing

    Network Interfaces: These are the physical or virtual interfaces that connect the Linux system to a network. Examples include Ethernet (eth0), Wi-Fi (wlan0), and loopback (lo). Protocol Handlers: The kernel uses protocol handlers to process different network protocols. For example, tcp_v4_rcv handles incoming TCP packets.

  26. Multicast Forwarding from eth0 to tun0 in Linux: A Step-by-Step Guide

    Set the IP address and netmask of the tun0 interface using the following commands: sudo ifconfig tun0 netmask . Replace and with the desired IP address and netmask for the tun0 interface. Step 2: Configure IP Multicast on the eth0 Interface. Once the tun0 interface is properly configured, we need to enable IP multicast on the eth0 interface.

  27. Quick Start Guide

    To determine the IP address of the switch, you can cross reference the MAC address of the switch with your DHCP server. The MAC address is typically located on the side of the switch or on the box in which the unit ships. To get started: Log in to Cumulus Linux on the switch and change the default credentials. Configure Cumulus Linux.