# Linux Router 筆記 ## Topology  ## Conf ### Ubuntu 16.04 * 把這台主機設定為**Host-Only** * 設定預設路由指向Linux Router ``` $ sudo route add default gw 10.0.0.129 ```  ### Linux Router * 當Router的這台須有**兩張網卡**,一張設定為**Bridge**一張設定為**Host-Only** * 然後必須打開**路由轉發**功能 ``` $ sudo vim /proc/sys/net/ipv4/ip_forward // 改為 1 $ sudo vim /etc/sysctl.conf net.ipv4.ip_forward = 1 $ sudo sysctl -p ``` ## Lab 1 * 上述設定無誤後,**My Host**也得設定一條路由到**Linux Router** ``` $ sudo route add default gw 192.168.1.100 ``` * **Ubuntu16.04**這台就可以跟外面的**My Host**連通  ## Lab 2 * 此時**Ubuntu16.04**這台是無法連上Internet的,還須設定NAT才行 `$ sudo iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -j SNAT --to 192.168.1.100` * **Ubuntu16.04**這台就可以正常上網  ## Reference * https://www.cnblogs.com/jjzd/p/6503020.html * https://blog.51cto.com/lustlost/943110
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up