{"id":86,"date":"2011-05-25T11:41:35","date_gmt":"2011-05-25T10:41:35","guid":{"rendered":"http:\/\/www.phillips321.co.uk\/?p=86"},"modified":"2011-05-25T19:02:54","modified_gmt":"2011-05-25T18:02:54","slug":"setting-up-networking-from-the-command-line","status":"publish","type":"post","link":"https:\/\/www.phillips321.co.uk\/2011\/05\/25\/setting-up-networking-from-the-command-line\/","title":{"rendered":"Setting up networking from the command line"},"content":{"rendered":"<p>So I&#8217;m often getting asked how to set up simple networking from the command line.<\/p>\n<p>This drives me nuts a simple google would get the answers!<\/p>\n<p>But, now I can just point people here and save wasting my time.<\/p>\n<p><strong>STATIC<\/strong><br \/>\nThe following presumes you are on a 192.168.1.n class C network  with the gateway as 192.168.1.1<\/p>\n<p>Linux<\/p>\n<div class=\"codecolorer-container bash vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/><\/div><\/td><td><div class=\"bash codecolorer\"><span class=\"kw2\">ifconfig<\/span> eth0 192.168.1.100 netmask 255.255.255.0 up<br \/>\nroute add default gw 192.168.1.1<br \/>\n<span class=\"kw3\">echo<\/span> <span class=\"st0\">&quot;nameserver 192.168.1.1&quot;<\/span> <span class=\"sy0\">&gt;&gt;<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>resolv.conf<br \/>\n<span class=\"co0\">#might need to restart networking<\/span><br \/>\n<span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>init.d<span class=\"sy0\">\/<\/span>network restart<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>Windows<\/p>\n<div class=\"codecolorer-container dos vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/><\/div><\/td><td><div class=\"dos codecolorer\">netsh interface ipv4 show interfaces #<a href=\"http:\/\/www.ss64.com\/nt\/in.html\"><span class=\"kw1\">in<\/span><\/a> order to identify the name of the interface<br \/>\nnetsh interface ipv4 <a href=\"http:\/\/www.ss64.com\/nt\/set.html\"><span class=\"kw3\">set<\/span><\/a> address name=\u201dLocal Area Connection\u201d source=static address=192.168.1.110 mask=255.255.255.0 gateway=192.168.1.1<br \/>\nnetsh interface ipv4 add dnsserver name=\u201dLocal Area Connection\u201d address=192.168.1.1 index=1<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>Solaris<\/p>\n<div class=\"codecolorer-container bash vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/><\/div><\/td><td><div class=\"bash codecolorer\"><span class=\"kw3\">echo<\/span> <span class=\"st0\">&quot;192.168.1.1&quot;<\/span> <span class=\"sy0\">&gt;&gt;<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>defaultrouter<br \/>\n<span class=\"kw3\">echo<\/span> <span class=\"st0\">&quot;192.168.1.100 HOSTNAME&quot;<\/span> <span class=\"sy0\">&gt;&gt;<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>inet<span class=\"sy0\">\/<\/span>hosts<br \/>\n<span class=\"kw3\">echo<\/span> <span class=\"st0\">&quot;nameserver 192.168.1.1&quot;<\/span> <span class=\"sy0\">&gt;&gt;<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>resolv.<br \/>\n<span class=\"kw2\">sed<\/span> <span class=\"re5\">-i<\/span> <span class=\"st0\">&quot;s\/hosts: file\/hosts: dns file\/g&quot;<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>nsswitch.conf<br \/>\n<span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>init.d<span class=\"sy0\">\/<\/span>network restart<br \/>\n<span class=\"co0\">#or just run<\/span><br \/>\n<span class=\"sy0\">\/<\/span>usr<span class=\"sy0\">\/<\/span>sbin<span class=\"sy0\">\/<\/span>sys-unconfig <span class=\"co0\">#and now reboot and enter details on the console<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p><strong>DHCP<\/strong><br \/>\nLinux<\/p>\n<div class=\"codecolorer-container bash vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"bash codecolorer\">dhclient eth0<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>Windows<\/p>\n<div class=\"codecolorer-container dos vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"dos codecolorer\">netsh interface ipv4 <a href=\"http:\/\/www.ss64.com\/nt\/set.html\"><span class=\"kw3\">set<\/span><\/a> address name=\u201dLocal Area Connection\u201d source=dhcp<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>Solaris<\/p>\n<div class=\"codecolorer-container bash vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"bash codecolorer\"><span class=\"sy0\">\/<\/span>usr<span class=\"sy0\">\/<\/span>sbin<span class=\"sy0\">\/<\/span>sys-unconfig <span class=\"co0\">#and now reboot and enter details on the console<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n","protected":false},"excerpt":{"rendered":"<p>So I&#8217;m often getting asked how to set up simple networking from the command line. This drives me nuts a simple google would get the answers! But, now I can just point people here and save wasting my time. STATIC The following presumes you are on a 192.168.1.n class C network with the gateway as [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,4],"tags":[48,49,5,6],"_links":{"self":[{"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts\/86"}],"collection":[{"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/comments?post=86"}],"version-history":[{"count":5,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts\/86\/revisions"}],"predecessor-version":[{"id":91,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts\/86\/revisions\/91"}],"wp:attachment":[{"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/media?parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/categories?post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/tags?post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}