{"id":1853,"date":"2011-10-23T10:26:40","date_gmt":"2011-10-23T02:26:40","guid":{"rendered":"http:\/\/www.jpuyy.com\/blog\/?p=1853"},"modified":"2021-06-13T06:23:47","modified_gmt":"2021-06-12T22:23:47","slug":"linux-static-ip-and-dns","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=1853","title":{"rendered":"linux\u8bbe\u7f6e\u9759\u6001ip\u53cadns"},"content":{"rendered":"<p>debian\u8bbe\u7f6e\u9759\u6001ip<\/p>\n<pre>#vim \/etc\/network\/interfaces<\/pre>\n<pre> auto eth0\r\n iface eth0 inet static\r\n address 219.230.144.244\r\n netmask 255.255.255.192\r\n gateway 219.230.144.254\r\n dns-nameservers 8.8.8.8<\/pre>\n<ul>\u91cd\u542f\u7f51\u7edc\u670d\u52a1<\/ul>\n<pre>\/etc\/init.d\/networking restart<\/pre>\n<p>ubuntu 20.04<\/p>\n<pre>\r\ncat \/etc\/netplan\/00-installer-config.yaml \r\n# This is the network config written by 'subiquity'\r\nnetwork:\r\n  ethernets:\r\n    enp4s0:\r\n      dhcp4: false\r\n      addresses:\r\n        - 192.168.1.66\/24\r\n      gateway4: 192.168.1.1\r\n      nameservers:\r\n          addresses: [192.168.1.1, 223.5.5.5]\r\n  version: 2\r\n<\/pre>\n<pre>netplan apply<\/pre>\n<p>centos\u8bbe\u7f6e\u9759\u6001ip<\/p>\n<p>#vim \/etc\/sysconfig\/network-scripts\/ifcfg-eth0 \u00a0\u6709\u65f6\u4f1a\u662fifcfg-em1<\/p>\n<pre>DEVICE=\"eth0\"\r\nBOOTPROTO=\"static\"\r\nHWADDR=\"00:A5:D1:EA:23:A4\"\r\nIPV6INIT=\"yes\"\r\nMTU=\"1500\"\r\nNM_CONTROLLED=\"yes\"\r\nONBOOT=\"yes\"\r\nTYPE=\"Ethernet\"\r\nUUID=\"95fd6b2b-ecfd-4cdf-9833-e3056f22d4e8\"\r\nIPADDR=192.168.8.126\r\nNETMASK=255.255.255.0\r\nGATEWAY=192.168.8.1<\/pre>\n<ul>\n<li>\n<h3>\u914d\u7f6edns\u89e3\u6790<\/h3>\n<\/li>\n<\/ul>\n<pre>echo \"nameserver 211.98.1.28\"&gt;&gt; \/etc\/resolv.conf<\/pre>\n<p>\u5f04\u5b8c\u540e\uff0c\u8bb0\u5f97\u91cd\u542f\u7f51\u7edc\u670d\u52a1<\/p>\n<pre>\/etc\/init.d\/network restart<\/pre>\n<p>\u67e5\u770b\u7f51\u7edcip<\/p>\n<pre>ifconfig<\/pre>\n<p>\u67e5\u770b\u7f51\u5173<\/p>\n<pre>netstat -rn<\/pre>\n<p>\u67e5\u770bnameserver<\/p>\n<pre>cat \/etc\/resolv.conf<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>debian\u8bbe\u7f6e\u9759\u6001ip #vim \/etc\/network\/interfaces auto eth0 iface eth0 inet static address 219.230.144.244 netmask 255.255.255.192 gateway 219.230.144.254 dns-nameservers 8.8.8.8 \u91cd\u542f\u7f51\u7edc\u670d\u52a1 \/etc\/init.d\/networking restart ubuntu 20.04 cat \/etc\/netplan\/00-installer-config.yaml # This is the network config written by &#8216;subiquity&#8217; network: ethernets: enp4s0: dhcp4: false addresses: &#8211; 192.168.1.66\/24 gateway4: 192.168.1.1 nameservers: addresses: [192.168.1.1, 223.5.5.5] version: 2 netplan apply centos\u8bbe\u7f6e\u9759\u6001ip #vim \/etc\/sysconfig\/network-scripts\/ifcfg-eth0 \u00a0\u6709\u65f6\u4f1a\u662fifcfg-em1 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[72],"class_list":["post-1853","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux-tips"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/1853","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1853"}],"version-history":[{"count":19,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/1853\/revisions"}],"predecessor-version":[{"id":9328,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/1853\/revisions\/9328"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}