2015年8月28日 星期五
ubuntu net setting
目前實驗室桌機有兩張網卡
eth0 對外,有實體IP
eth1 對內,本來接了一個 switch,分享eth0給 embedded system,兼用 bridge 分給 virtula machine
sudo vim /etc/network/interfaces
======
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 140.114.xx.xxx
netmask 255.255.255.0
gateway 140.114.xx.xxx
dns-nameservers 8.8.8.8 8.8.4.4
auto br0
iface br0 inet static
address 10.0.0.1
netmask 255.255.255.0
broadcast 10.0.0.255
gateway 10.0.0.1
bridge_ports eth1
bridge_stp off
bridge_maxwait 0
bridge_fd 0
======
REF:
http://selfdesigning.blogspot.tw/2014/12/ubuntu-docker.html
因為 eth0 eth1 是不同網段,所以利用 iptable 幫忙轉封包
======
sudo echo "1" > /proc/sys/net/ipv4/conf/all/forwarding
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
======
上面只是暫時的,重開機後就會不見,要永久的話要改設定
======
sudo sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf
sudo sysctl -p /etc/sysctl.conf
sudo apt-get install iptables-persistent
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo /etc/init.d/iptables-persistent save
======
REF:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Security_Guide/s1-firewall-ipt-fwd.html
http://linux.vbird.org/linux_server/0250simple_firewall.php#local_script
http://askubuntu.com/questions/119393/how-to-save-rules-of-the-iptables
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言