Networking Basics (20090405)

From FedoraProject

Jump to: navigation, search

IRC Log

@spevack anyway nirik, whenever you are ready, it's all yours 14:52
nirik well, hopefully everyone had a minute or two to take a quick break. Shall we get started on the next class? 14:52
dash123 yes master 14:52
Padhu1 yes sir 14:52
nirik hello everyone. I'm Kevin Fenzi and will be talking about Fedora networking today. 14:52
mahesh nirik hello 14:53
nirik this is another topic that is very large and can be complex, so feel free to ask questions and we can steer the class in the direction everyone is interested in. 14:53
Padhu1 ok nirik 14:53
nirik I'd like to start out by talking about the 2 frameworks that Fedora has for handling your networking. 14:54
Padhu1 m 14:54
nirik First, there is the 'network' service. Many of your may know this as it's been used by fedora for a long time. 14:54
nirik it's a setup using configuration scripts. I will talk about them in more detail in a few. 14:55
nirik Then, in newer fedora versions there is a product called NetworkManager that manages the network setup. 14:56
Padhu1 yes 14:56
nirik It's a program that can read the old network scripts, but can also do some more complex things with wireless and passwords and so forth. 14:56
Padhu1 yeah 14:56
jyoti Are they fundamentally different? I thought one runs above the other? Is it not that? 14:56
nirik finally you can if you choose manage your network manually from the command line using low level tools. I can talk about that as well if there is interest. 14:56
l0nwlf yes , please do so 14:57
SSlater yes 14:57
Padhu1 yes please 14:57
... signoff!#fedora-classroom -> megenius_(Read error: 110 (Connection timed out)) 14:57
nirik jyoti: they are in fact different. There is overlap in that they can read the same config files. You can if you choose use both of them. ;) 14:57
nirik ok, so lets take things from lowest level to higher then... looking first at command line tools. 14:58
Padhu1 ok 14:58
nirik First of all to assign an IP address to your computer you will need to use either ifconfig or a dhcp client tool. 14:59
nirik ifconfig can be a complex command, but a simple invocation might look like: 'ifconfig eth0 up 192.168.1.10 netmask 255.255.255.0' 14:59
nirik This tells the kernel to bring up the 'eth0' network interface with the ip address 192.168.1.10 and assign it a network mask of 255.255.255.0 15:00
nirik You can see a lot more info on the things it can do in 'man ifconfig' 15:00
nirik If your network has a dhcp server on it, that would take care of assigning ip addresses, and you could do something like 'dhclient eth0' to ask for an address. 15:01
nirik You can also run a 'ifconfig eth0' for example to get information about your current interface. 15:01
Padhu1 sir, how can i set gateway in static 15:02
mahesh ifconfig etho0 will set a temp ip which will expire within mins i guess right ? 15:02
nirik Padhu1: good question. That brings us to routing... just getting an IP address on your network will allow you to talk to it, but you need a route to tell your kernel where to send traffic that is not for your local network. 15:02
mahesh sorry ifconfig eth0* 15:03
nirik mahesh: no, it will never expire.. you have manually added it, and it will stay. ;) dhcp addresses can expire however, depending on how the server is configured. 15:03
... join!#fedora-classroom -> yunustj(n=yunusf10@fedora/yunustj) 15:04
mahesh so if i have dhcp configured server, it would expire my ip 15:04
nirik any other questions on ifconfig ? shall I move on to routing ? 15:04
jyoti nirik, even after reboot? 15:04
... leave!#fedora-classroom -> sadfag() 15:04
Padhu1 How can i make multiple IPs 15:05
* l0nwlf have a question ? 15:05
nirik mahesh: it can, depending on how it's setup. Most of them would expire after a time, but your machine can request a renewed ip... 15:05
mahesh ok 15:05
nirik jyoti: no, that would only last until reboot, good point. 15:05
nirik go ahead l0nwlf 15:05
l0nwlf Can I set my IP, gateway, DNS, subnet-mask all from ifconfig command ? 15:06
* nirik notes the higher level tools (network/NetworkManager) make most of this all transparent, but it's good to know whats going on behind the scenes. ;) 15:06
UsamaAkkad yeah right 15:06
nirik l0nwlf: ifconfig will let you set your IP/subnet mask. The 'route' command will let us see and set the gateway/routing. DNS is in a /etc/resolv.conf file. 15:07
Padhu1 How can i make multiple IPs for single Ethernet card? 15:07
UsamaAkkad Padhu1: you are rushing I guess 15:07
nirik Padhu1: You can setup aliased interfaces. So, simpliest case: 'ifconfig eth0:0 up 192.168.10.10' 15:07
Padhu1 oh 15:07
nirik Padhu1: then you would have a eth0 and an eth0:0 with different ip's. ;) 15:08
UsamaAkkad lets understand the basic thing first 15:08
l0nwlf but there is DNS entry in my ifcfg-eth0 15:08
jyoti nirik, you know there is no use editing /etc/resolv.conf by hand the changes are not used... the changes get used only when nm modifies it... that is what i experienced... 15:08
nirik l0nwlf: yes, we will get to that. 15:08
nirik jyoti: yep. Changing things behind the tools back means that they can change them again. ;) 15:08
nirik lets move on quickly to route and then talk about network and NetworkManager a bit. 15:09
Padhu1 ok sir 15:09
nirik the route command will show you network routes. I usually use -n with it so it doesn't do any dns lookups and is faster... 15:09
nirik route -n 15:09
nirik when you use ifconfig it will automatically make a network route to your local network 15:09
... signoff!#fedora-classroom -> kulll(Read error: 110 (Connection timed out)) 15:09
nirik but it doesn't make a default route that tells where to send any traffic thats not going to your network. 15:10
nirik if you run a 'route -n' now you can see you likely have a route at the bottom of the list showing '0.0.0.0... ' 15:10
nirik thats the default route. 15:10
l0nwlf http://www.mibbit.com/pb/z0ENsg 15:10
nirik for example, mine looks like: 15:11
nirik 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0 15:11
UsamaAkkad sorry 15:11
nirik l0nwlf: yeah, so the first one is your network route. Anything in that ip range/subnet goes locally to your network. 15:11
nirik l0nwlf: the next one says anything else should go to that gateway. ;) 15:11
... join!#fedora-classroom -> kulll(n=kulll@203.82.91.34) 15:12
nirik any questions on routes? You can of course have much more complex routing... 15:12
jyoti I love route -nee :) 15:12
Padhu1 How can i set default gateway? 15:13
SSlater Looks like have no gateway set. How to do that? 15:13
nirik Padhu1 / SSlater: excellent question. ;) 15:13
G__81 Padhu, there is an option in the route command default gw 15:13
G__81 which sets it 15:13
nirik route add default gw 192.168.1.1 dev wlan0 15:13
G__81  :) 15:14
nirik route can add/delete/change existing routes. The above will add a new default route with that gateway (gw) and using that dev 15:14
Padhu1 only for devices? 15:14
nirik note that if you are using dhclient, most likely it would get the gateway from your dhcp server and setup this route for you. 15:15
Padhu1 oh 15:15
SSlater nirik: I get an error - SIOCADDRT: No such process 15:15
nirik you can leave off the 'dev wlan0' or whatever if you like, route can figure out which device you talk to the gateway over and default to that. 15:15
nirik SSlater: make sure you can reach the gateway ip you are specifying... if not you may need to add a route to it first. 15:16
nirik again, this usually is taken care of for you by the high level tools. 15:17
Padhu SSlater: don't try it now please 15:17
nirik I'll quickly mention DNS is configured in the /etc/resolv.conf file. As jyoti mentioned you don't want to change this if you are using network/NetworkManager as they may change it 15:18
l0nwlf Let's say I'm using eth0 and I created an eth1 file to test the command but it's saying no device 15:18
... join!#fedora-classroom -> foolish(n=foolish@fedora/foolish) 15:19
SSlater Works now. 15:19
nirik l0nwlf: ifconfig won't let you create a new device. ;) If you only have a eth0 then you only have a eth0. ;) 15:19
... signoff!#fedora-classroom -> SSlater(Read error: 54 (Connection reset by peer)) 15:19
nirik l0nwlf: you can make a eth0:0 or the like alias interface that uses the same eth0 physical interface if you want tho. 15:19
mahesh but i think etho:1 is possible virtual 15:19
l0nwlf oops , I can't test right now or else I'll get disconnected 15:19
mahesh eth0:1 15:19
... join!#fedora-classroom -> SSlater(n=simon@124-168-17-4.dyn.iinet.net.au) 15:19
nirik yeah, carefull testing right now. ;) 15:20
... signoff!#fedora-classroom -> sattam1(Read error: 92 (Protocol not available)) 15:20
nirik mahesh: yes, you can number it whatever you like in fact... 15:20
Padhu1 nirik: sir, is it possible to alias different class networks? 15:20
mahesh ok 15:20
... join!#fedora-classroom -> GeroldKa(n=GeroldKa@fedora/geroldka) 15:20
nirik Padhu1: not sure I understand the question... what do you mean by class? 15:20
nirik you can make aliases of any physical device... eth0, wlan0, etc. 15:21
G__81 class a/b/c ? 15:21
Padhu1 192 series and 172 series IPs in aliases 15:21
Padhu1 exactly 15:21
nirik ah, different networks. sure. You can have eth0 and eth0:0 on different networks just fine. 15:21
G__81 yes if you give the appropriate masks & ip range it will work 15:22
nirik ok, shall we move on to talk about network scripts / config? 15:22
mahesh ok 15:22
SSlater yep. 15:22
Padhu1 what about routes/ gateways 15:22
l0nwlf well Padhu1 you mean Like I have 1 card , and 2 network-set (let's assume one of my hostel and another of my lab) so I can create eth0,etho:0 and manually up/down ? 15:23
nirik Padhu1: you can use 'route' to set those up as well. Note that you can only have one default gateway (well, you can have moree than one, but only one matters) 15:23
... signoff!#fedora-classroom -> ideamonk("Leaving") 15:23
Padhu1 oh. 15:23
nirik ok, so both network and NetworkManager use some config files to describe your setup. 15:23
Padhu1 m 15:24
nirik these can be found in: /etc/sysconfig/network-scripts/ and /etc/sysconfig/network (a file) 15:24
mahesh if-cfg file 15:24
nirik the network file has some high level info... like what your hostname is, if you want networking enabled and so forth. 15:24
nirik it may also have gateway info in it. 15:25
nirik under /etc/sysconfig/network-scripts/ there will be 'ifcfg-INTERFACENAME' files... so a 'ifcfg-eth0' 'ifcfg-wlan0' ifcfg-eth1' etc. 15:25
nirik Those files describe that specific interface. 15:25
Padhu1 oh. If i have an dhcp? 15:26
nirik They can have a static ip address config, or dhcp 15:26
Padhu1 oh 15:26
* G__81 wants everyone to recollect on how an interface is created. this was explained yesterday in netlink session :) 15:26
mahesh ok 15:26
Padhu1 ok G_81 15:26
nirik there can also be more info in there like wireless networks, MAC address, etc. 15:26
Padhu1 please cary on 15:27
nirik I'll note now that there is a tool called 'system-config-network' that can manage these files for you. 15:27
nirik in that tool you can add/edit/modify the interfaces. 15:27
nirik in the config files there is a config that would look like: 15:28
nirik NM_CONTROLLED=yes (or no). This is important as it tells if 'network' or 'NetworkManager' should control that interface. 15:28
Padhu1 oh 15:29
nirik The 'network' service reads those config files above and runs on boot. It's disabled by default in favor of NetworkManager in recent fedora versions. 15:29
UsamaAkkad and how to disable networkmanger 15:29
UsamaAkkad once I wanted to use wvdial but I couldnt' 15:30
nirik There are still some cases where you might want network over NetworkManager. 15:30
l0nwlf NM means nmapplet , top right icon ? 15:30
... signoff!#fedora-classroom -> CheekyBoinc("Use Fedora Linux -> fedoraproject.org ++ www.cheekyboinc.de ++") 15:30
nirik UsamaAkkad: you can set NM_CONTROLLED=no on the interfaces, and 'chkconfig network on' 15:30
Padhu1 nirik: sir, you missed to point out start-up configuration of network 15:30
l0nwlf I use network over network manager , because my settings were all grayed out , don't know why ? 15:30
UsamaAkkad thanks 15:31
nirik l0nwlf: yes, the nm-applet talks to NetworkManager, will get to that in a few. ;) 15:31
UsamaAkkad is there record for this channel? 15:31
nirik Padhu1: yeah, network is disabled by default. If you want to start it up, you can use chkconfig or system-config-services to enable it. 15:31
UsamaAkkad I've to go 15:31
nirik UsamaAkkad: yep. ;) will be a log. 15:32
UsamaAkkad nice, where ? 15:32
nirik on the wiki page in the topic. ;) Linked to the class name. 15:32
Padhu1 oh 15:32
SSlater Does Fedora use an /etc/network/interfaces file? 15:32
Padhu1 SSlater: no 15:32
nirik SSlater: it does not... the config is under /etc/sysconfig/network-scripts/ 15:32
SSlater Ok. 15:33
nirik ok, any questions on network service before I move on to NetworkManager? 15:33
Padhu1 SSlater: you are talking about debian or its derivatives 15:33
... signoff!#fedora-classroom -> UsamaAkkad("bye") 15:33
Padhu1 no questions 15:33
Padhu1 wireless services 15:34
nirik note that NetworkManager can/will read the same /etc/sysconfig/network-scripts/ config files as network... unless NM_CONTROLLED=no (then it ignores that interface) 15:34
nirik ok, NetworkManager is a new service that handles networking. 15:34
nirik It's got advantages over network in many cases. It can handle wireless networks with passphrases and cases such as that, as well as the normal cases. 15:34
nirik it runs in the background watching your network setup and communicates to you via the 'nm-applet' applet in your system tray. 15:35
... signoff!#fedora-classroom -> GeroldKa(Remote closed the connection) 15:35
Padhu1 m 15:35
nirik From there you can join wireless networks, enable/disable wired connections, or connect to cell data cards, etc. 15:36
l0nwlf nirik: one question , In my case I had set IP and other settings in NM but when I checked for ifcfg-eth0 files , there was nothing ? Is it true that NM takes the setting from same file 15:36
nirik l0nwlf: it can. It can also store them internally. It depends on how you made the config. If it's with nm-applet, it will store it internally by default. 15:36
Padhu1 l0nwlf:: just restart the network service 15:37
... join!#fedora-classroom -> ranna(n=ranna@user-0c8h9pu.cable.mindspring.com) 15:37
nirik if you use system-config-network to do it it will save it in the ifcfg type files. 15:37
l0nwlf i made it with nm-applet , so it must store it internally 15:37
nirik I'd like to touch on some nice features of NetworkManager/tools for it. 15:37
nirik One nice one is the 'nm-tool' command. 15:37
Padhu1 oh 15:38
nirik this will show you the config of NetworkManager. You can see what states all it's interfaces are in and if they are managed, etc. 15:38
Padhu1 in terminal? 15:38
nirik yes, it's a terminal/command line command. 15:38
nirik here is my output: http://fpaste.org/paste/8024 15:39
nirik so you can see I have a eth0, but it's not connected, a wiress that is connected and active, and a mobile broadband thats not connected. 15:39
nirik nm-tool is handy when trying to see what your current network state is. 15:40
... signoff!#fedora-classroom -> openpercept("Leaving") 15:40
... signoff!#fedora-classroom -> indSpike("Leaving.") 15:40
Padhu1 yes. i saw the link 15:40
nirik There are a lot of things you can configure in the nm-applet tool as well. You can in there edit connections and set various things on them. 15:40
Padhu1 please tach us 15:41
Padhu1 teach 15:41
nirik if you right click on the applet it should give you a 'edit connections' option. 15:41
nirik then it should pull up an editor. You can see the wired/wireless/etc tabs. 15:41
Padhu1 oh 15:42
mahesh yes 15:42
Padhu1 yeah 15:42
nirik you can set things under each interface like dns servers you would like, etc. 15:42
nirik For wireless you can set if you want to connect to that network automatically or not and other items. 15:43
mahesh to make things easy i always select auto eth0 in that applet 15:43
Padhu1 +1 15:43
nirik NetworkManager also has some plugins for VPN. If you have those installed, you can configure a virtual private network in there as well. 15:43
mahesh ok 15:44
nirik we are starting to run low on time, so any questions on anything so far? 15:44
nirik this is really a big topic. ;) 15:44
mahesh keep going 15:45
G__81  :) its got networking which is a big topic by itself and its also got fedora's tools :) which is an other big topic :) 15:45
nirik can do. ;) 15:45
Padhu1 no questions. please carry on 15:45
nirik ok, a quick note about startup with NetworkManager. 15:45
nirik It will start on boot and configure any networks you have ifcfg- scripts for. 15:45
Padhu1 yes 15:45
nirik just like network. 15:45
nirik However, it cannot join you to wireless networks on boot, you must login. This is due to it using your users keyring to store any passphrases you need to join those wireless networks. 15:46
... join!#fedora-classroom -> GeroldKa(n=GeroldKa@fedora/geroldka) 15:46
nirik So, if you are using wireless and it doesn't come up on boot, you need to remember to login. :) 15:47
Padhu1 oh 15:47
mahesh ok 15:47
... signoff!#fedora-classroom -> jyoti(Remote closed the connection) 15:47
nirik as I mentioned eariler you can also use both if you want. Use system-config-network and/or edit the ifcfg- files to use the NM_CONTROLLED value to see which one controls which interrface. 15:48
nirik oh, another nice thing with NetworkManager I wanted to mention. 15:48
nirik If you want to run some script when you connect/disconnect to a network, you can make a script and place it in /etc/NetworkManager/dispatcher.d/ 15:49
nirik NM will read scripts in there and run them on connect/disconnect. 15:49
Padhu1 one example please 15:49
nirik if you take a look in there, you likely have a few system provided ones. Let me give an example tho 15:49
nirik sendmail places a simple one in there that looks like: 15:50
nirik #!/bin/sh 15:50
nirik if [ "$2" = "up" ] [ "$2" = "down" ]; then 15:50
nirik /sbin/service sendmail reload  : 15:50
nirik fi 15:50
nirik you can see the script is passed 'up' or 'down' if the network is being connected/disconnected. 15:51
nirik you can run a particular action on that. 15:51
Padhu1 oh. 15:51
nirik this is handy if you have some resource you want to connect to on ever network connection. 15:51
Padhu1 How to watch out IP conflicts? 15:52
nirik Padhu1: good question. There is some automatic detection of conflicts... so if you use network or NM it will tell you and refuse to use the ip. 15:52
nirik if you manually use ifconfig you may bypass the detection. 15:53
nirik if you use dhcp your dhcp server should handle all that. 15:53
mahesh ok 15:53
Padhu1 Is it display the MAC Addess of ethernet device which is already have the same ip? 15:53
nirik yes, it would. 15:54
Padhu1 oh 15:54
... signoff!#fedora-classroom -> G__81("Leaving") 15:54
... signoff!#fedora-classroom -> kulll(Read error: 110 (Connection timed out)) 15:54
nirik another nice feature NetworkManager has is if you are on wired and have a wireless card. You can share your connection to users on wireless. 15:54
Padhu1 m 15:55
nirik simply left click on the nm-applet and select 'create new wireless network'. Give it a name and say ok. 15:55
nirik then other wireless uses should see it and be able to use your machine as their gateway. 15:55
Padhu1 you mean proxy? 15:55
nirik it will act as a default gateway and send all their traffic to/from the wired connection. 15:56
Padhu1 or router 15:56
Padhu1 oh 15:56
* nirik sees we are somewhat out of time now. 15:56
nirik any last minute questions on any networking items? 15:56
SSlater DHCP next month? 15:57
Padhu1 SSlater: DHCP Server? 15:57
... join!#fedora-classroom -> sattam(n=sattam@unaffiliated/thtoh) 15:57
nirik we could do a dhcp class... both client and server setup would be interesting. 15:57
... join!#fedora-classroom -> kulll(n=kulll@203.82.79.2) 15:57
Padhu1 oh. 15:57
mahesh sure 15:57
SSlater Could have used it last week ... have to wait. 15:58
nirik anyhow, thanks for coming everyone. :) Feel free to ask any further networking questions over in #fedora, or here if you like. ;) 15:58
@spevack nirik: thanks for running the class! 15:58
nirik no problem. Happy to teach. 15:59
Padhu1 nirik: THank you sir. 15:59
SSlater Thank you nirik! 15:59

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!